RFR: 8366736: Closed System.out causes child process to hang on Windows [v2]
Ioi Lam
iklam at openjdk.org
Mon Jan 19 20:24:51 UTC 2026
On Wed, 14 Jan 2026 14:40:04 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> The change in behavior should be documented in an APINote on Process.inheritIO() to say that the output is discarded if it has been closed.
I added an APINote for `Process.inheritIO()`:
* @apiNote
* If {#code System.out} and/or {#code System.err} have been
* closed in the current process, the corresponding output
* in the subprocess will be discarded.
> src/java.base/windows/classes/java/lang/ProcessImpl.java line 133:
>
>> 131: if (stdHandles[1] == -1L) {
>> 132: // FileDescriptor.out has been closed.
>> 133: f1 = setFileOutput(Redirect.DISCARD, stdHandles, 1);
>
> More compact yes, but I prefer to update local state inline, its easier to see the consistent pattern of state updates across the different cases.
I updated the code as you suggested.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29198#issuecomment-3769993899
PR Review Comment: https://git.openjdk.org/jdk/pull/29198#discussion_r2705980676
More information about the core-libs-dev
mailing list