8184808: (process) isAlive should use pid for validity, not /proc/pid
authorrriggs
Wed, 19 Jul 2017 16:24:38 -0400
changeset 45926 43879a69df50
parent 45925 1771cc023624
child 45927 85a466ecd6fb
8184808: (process) isAlive should use pid for validity, not /proc/pid Reviewed-by: stuefe, xiaofeya
jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
--- a/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Wed Jul 19 19:31:48 2017 +0100
+++ b/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Wed Jul 19 16:24:38 2017 -0400
@@ -662,6 +662,11 @@
         return -1;
     }
 
+    // Validate the pid before returning the info in case /proc/pid is racy
+    if (kill(pid, 0) < 0) {
+        return -1;
+    }
+
     *totalTime = psinfo.pr_time.tv_sec * 1000000000L + psinfo.pr_time.tv_nsec;
 
     *startTime = psinfo.pr_start.tv_sec * (jlong)1000 +