8315026: ProcessHandle implementation listing processes on AIX should use getprocs64

Reviewed-by: rriggs, stuefe, mbaesken
This commit is contained in:
Joachim Kern 2023-10-13 08:29:48 +00:00 committed by Matthias Baesken
parent 1082c0e767
commit 4d9042043e
2 changed files with 139 additions and 9 deletions

View file

@ -488,15 +488,25 @@ void unix_getUserInfo(JNIEnv* env, jobject jinfo, uid_t uid) {
* The following functions are common on Solaris, Linux and AIX.
*/
#if defined (__linux__) || defined(_AIX)
#if defined (__linux__)
/*
* Returns the children of the requested pid and optionally each parent and
* start time.
* Reads /proc and accumulates any process who parent pid matches.
* The resulting pids are stored into the array of longs.
* Return pids of active processes, and optionally parent pids and
* start times for each process.
* For a specific non-zero pid, only the direct children are returned.
* If the pid is zero, all active processes are returned.
* Reads /proc and accumulates any process following the rules above.
* The resulting pids are stored into an array of longs named jarray.
* The number of pids is returned if they all fit.
* If the array is too short, the negative of the desired length is returned.
* If the parentArray is non-null, store also the parent pid.
* In this case the parentArray must have the same length as the result pid array.
* Of course in the case of a given non-zero pid all entries in the parentArray
* will contain this pid, so this array does only make sense in the case of a given
* zero pid.
* If the jstimesArray is non-null, store also the start time of the pid.
* In this case the jstimesArray must have the same length as the result pid array.
* If the array(s) (is|are) too short, excess pids are not stored and
* the desired length is returned.
*/
jint unix_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray,
jlongArray jparentArray, jlongArray jstimesArray) {
@ -607,7 +617,7 @@ jint unix_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray,
return count;
}
#endif // defined (__linux__) || defined(_AIX)
#endif // defined (__linux__)
/*
* The following functions are for AIX.