8177932: (process) java/lang/ProcessHandle/OnExitTest.java failed with "Process A should not be alive..."
Reviewed-by: stuefe, dholmes, fyuan
--- 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;
}