RFR: 8364361: [process] java.lang.Process should implement Closeable [v13]
Roger Riggs
rriggs at openjdk.org
Wed Oct 1 13:03:42 UTC 2025
On Wed, 1 Oct 2025 12:21:58 GMT, Jason Mehrens <duke at openjdk.org> wrote:
>> Roger Riggs has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Additional review feedback.
>> Updated to emphasize reading the data from the streams and calling waitFor
>> to allow for normal termination.
>
> src/java.base/share/classes/java/lang/Process.java line 205:
>
>> 203: * On some platforms, {@linkplain #supportsNormalTermination() normal termination}
>> 204: * is not available and the process is forcibly terminated.
>> 205: * The {@linkplain #waitFor() waitFor} method SHOULD NOT be called after
>
> Calling waitFor with a timeout is a must for escalation of process termination. E.G. TWR + finally waitFor with timeout. Then destroy with force. Optionally waitFor again if we need to know process is terminated.
>
> It is not waitFor that should not be used. It is the result of exitValue or waitFor may or may not be a normal value from the process after any destroy method.
@jmehrens I think I understand your point. Does this capture it:
* Calling {@linkplain #waitFor() waitFor} after
* {@linkplain #close() close} or after the try-with-resources block exits
* can verify that the process has been terminated.
* The status returned may be from normal termination or the result of
* {@link #destroy() destroying the process}.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2394495843
More information about the core-libs-dev
mailing list