RFR: 8333742: ProcessImpl and ProcessHandleImpl may mishandle processes that exit with code 259
Daniel Jeliński
djelinski at openjdk.org
Fri Jun 7 09:48:21 UTC 2024
`GetExitCodeProcess` method is not reliable for checking if a process exited already; it returns 259 (STILL_ACTIVE) if the process hasn't exited yet, but the same value is returned when the process exited with code 259. In order to check if the process exited, we need to check if its handle is in a signaled state using one of the wait methods.
This PR fixes the onExit, exitValue, isAlive, and waitFor(timeout) methods to correctly handle the problematic exit code.
I haven't fixed the ProcessImpl.toString method. I'm not sure the problem is important enough to justify an extra JNI call in the (probably typical) still-alive case.
Tier1-3 testing clean. I modified the existing OnExitTest to cover this case.
-------------
Commit messages:
- More precise comment
- exit waitForProcessExit on interrupt
- Exclude test for exit code 259 on non-Windows systems
- Fix waitFor
- Fix onExit, exitValue and isProcessAlive
Changes: https://git.openjdk.org/jdk/pull/19586/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19586&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8333742
Stats: 58 lines in 4 files changed: 27 ins; 16 del; 15 mod
Patch: https://git.openjdk.org/jdk/pull/19586.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19586/head:pull/19586
PR: https://git.openjdk.org/jdk/pull/19586
More information about the core-libs-dev
mailing list