8177932: (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive..."
authorrriggs
Thu, 21 Sep 2017 11:41:34 -0400
changeset 47236 bed98952fb09
parent 47235 9ef10c6e67b8
child 47237 8a24c04f37c5
8177932: (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive..." Reviewed-by: stuefe, dholmes, fyuan
src/java.base/share/classes/java/lang/ProcessHandleImpl.java
src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
--- a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java	Thu Sep 21 11:41:12 2017 -0400
+++ b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java	Thu Sep 21 11:41:34 2017 -0400
@@ -151,9 +151,9 @@
                                 } catch (InterruptedException ie) {
                                     // ignore and retry
                                 }
-                                startTime = isAlive0(pid);  // recheck if is alive
-                                if (origStart > 0 && startTime != origStart) {
-                                    // start time changed, pid is not the same process
+                                startTime = isAlive0(pid);  // recheck if it is alive
+                                if (startTime > 0 && origStart > 0 && startTime != origStart) {
+                                    // start time changed (and is not zero), pid is not the same process
                                     break;
                                 }
                             }
--- a/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Thu Sep 21 11:41:12 2017 -0400
+++ b/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c	Thu Sep 21 11:41:34 2017 -0400
@@ -662,7 +662,7 @@
         return -1;
     }
 
-    // Validate the pid before returning the info in case /proc/pid is racy
+    // Validate the pid before returning the info
     if (kill(pid, 0) < 0) {
         return -1;
     }