On Thu, 4 Sep 2025 12:28:15 GMT, David Lloyd <[email protected]> wrote:
>> `DestroyForcibly` is an escalation that should only be used with a known >> poorly behaved process; and that's up to the programmer. It is the >> equivalent of `kill -9`. >> It should not be used in the normal case. Unfortunately, Windows does not >> have a polite, please terminate API so `destroy` has the same behavior as >> `destroyForcibly`. >> If the caller uses `process.waitFor()` within the try-catch, the process >> will have terminated, possibly based on the stream closings, and `destroy()` >> will not be called. >> If emphasis is needed, the javadoc can elaborate. > >> `DestroyForcibly` is an escalation that should only be used with a known >> poorly behaved process; and that's up to the programmer. It is the >> equivalent of `kill -9`. It should not be used in the normal case. >> Unfortunately, Windows does not have a polite, please terminate API so >> `destroy` has the same behavior as `destroyForcibly`. > > This is my point exactly; the behavior will differ between Windows and > non-Windows. (I didn't want to name-and-shame any particular OS though.) :-) > >> If the caller uses `process.waitFor()` within the try-catch, the process >> will have terminated, possibly based on the stream closings, and `destroy()` >> will not be called. If emphasis is needed, the javadoc can elaborate. > > OK. Clarifying in the javadoc would be option three then (the other two > options being the two ways mentioned to make the behavior equitable between > platforms). Added a description of how destroy behaves, normal termination, and a suggestion to call `waitFor` to allow for clean up and normal exit. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2323627946
