# HG changeset patch # User rriggs # Date 1506008494 14400 # Node ID bed98952fb091409c10c7767274926c948e52da8 # Parent 9ef10c6e67b881562b92612fd7f6c5986a1c18e4 8177932: (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive..." Reviewed-by: stuefe, dholmes, fyuan diff -r 9ef10c6e67b8 -r bed98952fb09 src/java.base/share/classes/java/lang/ProcessHandleImpl.java --- 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; } } diff -r 9ef10c6e67b8 -r bed98952fb09 src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c --- 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; }