On Sun, 15 Feb 2026 06:01:02 GMT, Ioi Lam <[email protected]> wrote:
>> The bug is here on line 121:
>>
>> https://github.com/openjdk/jdk/blob/586846b84a38d285c5905437e903cfc57f609410/src/java.base/windows/classes/java/lang/ProcessImpl.java#L118-L121
>>
>> If `System.out` has been closed, `fdAccess.getHandle()` will return -1. This
>> causes `stdHandles[1]` to have the same value as if the child process's
>> stdout was redirected with `Redirect.PIPE`. This will cause a Pipe to be
>> created here for the child process's STDOUT on line 168:
>>
>> https://github.com/openjdk/jdk/blob/586846b84a38d285c5905437e903cfc57f609410/src/java.base/windows/native/libjava/ProcessImpl_md.c#L158-L184
>>
>> However, the caller of the `ProcessBuilder` is not aware of this and will
>> not drain this pipe. This causes the child process to get stuck when writing
>> to its stdout when the pipe 's buffer is filled up.
>>
>> The fix is to treat the redirection as `Redirect.DISCARD` when `System.out`
>> and/or `System.err` have been closed.
>
> Ioi Lam has updated the pull request with a new target base due to a merge or
> a rebase. The incremental webrev excludes the unrelated changes brought in by
> the merge/rebase. The pull request contains 11 additional commits since the
> last revision:
>
> - Review comment by @AlanBateman: use implNote instead. Also fixed
> whitespaces
> - Merge branch 'master' into
> 8366736-closed-system-out-causes-child-process-to-hang-on-windows
> - @RogerRiggs review comments
> - Fixed typo
> - fixed typo
> - Merge branch 'master' into
> 8366736-closed-system-out-causes-child-process-to-hang-on-windows
> - Review comments from @RogerRiggs
> - Reverted previous unintended commit
> - 8375654: Exclude all array classes from dynamic CDS archive
> - Review comments from @RogerRiggs
> - ... and 1 more: https://git.openjdk.org/jdk/compare/f3eaab4c...bc999867
src/java.base/share/classes/java/lang/ProcessBuilder.java line 935:
> 933: * @implNote
> 934: * When the process is {@link #start started},
> 935: * if {#code System.out} and/or {#code System.err} have been
Thanks for moving it to an implNote. For word smithing, It might be better to
say "and System.out and/or System.err has been closed". Also it would be better
to say the current VM rather than the current process here as these APIs relate
to the current VM.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29198#discussion_r2815168712