Skip to content

Commit fe217e4

Browse files
author
duke
committedJan 9, 2025
Automatic merge of jdk:master into master
2 parents f8f2e5d + f9b1133 commit fe217e4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed
 

‎src/java.base/aix/native/libjava/ProcessHandleImpl_aix.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,24 @@ jint os_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray,
162162
}
163163

164164
pid_t os_getParentPidAndTimings(JNIEnv *env, pid_t pid, jlong *total, jlong *start) {
165-
return unix_getParentPidAndTimings(env, pid, total, start);
165+
pid_t the_pid = pid;
166+
struct procentry64 ProcessBuffer;
167+
168+
if (getprocs64(&ProcessBuffer, sizeof(ProcessBuffer), NULL, sizeof(struct fdsinfo64), &the_pid, 1) <= 0) {
169+
return -1;
170+
}
171+
172+
// Validate the pid before returning the info
173+
if (kill(pid, 0) < 0) {
174+
return -1;
175+
}
176+
177+
*total = ((ProcessBuffer.pi_ru.ru_utime.tv_sec + ProcessBuffer.pi_ru.ru_stime.tv_sec) * 1000000000L) +
178+
((ProcessBuffer.pi_ru.ru_utime.tv_usec + ProcessBuffer.pi_ru.ru_stime.tv_usec));
179+
180+
*start = ProcessBuffer.pi_start * (jlong)1000;
181+
182+
return (pid_t) ProcessBuffer.pi_ppid;
166183
}
167184

168185
void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) {

0 commit comments

Comments
 (0)
Please sign in to comment.