On Tue, 5 Aug 2025 18:21:24 GMT, Roger Riggs <[email protected]> wrote:
> The teardown of a Process launched by `ProcessBuilder` includes the closing
> of streams and ensuring the termination of the process is the responsibility
> of the caller. The `Process.close()` method provides a clear and obvious way
> to ensure all the streams are closed and the process terminated.
>
> The try-with-resources statement is frequently used to open streams and
> ensure they are closed on exiting the block. By implementing
> `AutoClosable.close()` the completeness of closing the streams and process
> termination can be done by try-with-resources.
>
> The actions of the `close()` method are to close each stream and destroy the
> process if it has not terminated.
src/java.base/share/classes/java/lang/Process.java line 631:
> 629: * Streams should be {@code closed} when no longer needed.
> 630: * Closing an already closed stream usually has no effect but is
> specific to the stream.
> 631: * IOExceptions that occur when closing streams are ignored.
Suggestion:
* Any {@code IOException} that occurs when closing a stream is ignored.
src/java.base/share/classes/java/lang/Process.java line 635:
> 633: * The process may already have exited or be in the process of
> exiting;
> 634: * if it is {@linkplain #isAlive() alive}, it is {@linkplain
> #destroy destroyed}.
> 635: * IOExceptions that occur when destroying the process are ignored.
Suggestion:
* Any {@code IOException} that occurs when destroying the process is
ignored.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2255930745
PR Review Comment: https://git.openjdk.org/jdk/pull/26649#discussion_r2255931623