Skip to content

Close process streams after exit to work around JDK-4311711 hang#412

Open
elharo wants to merge 1 commit into
masterfrom
fix/process-streams-close
Open

Close process streams after exit to work around JDK-4311711 hang#412
elharo wants to merge 1 commit into
masterfrom
fix/process-streams-close

Conversation

@elharo

@elharo elharo commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

After Process.waitFor() returns, close the process's stdout, stderr, and stdin streams. This works around JDK-4311711 where Process.getInputStream().read() can hang indefinitely even after the process has terminated.

Without this fix, CommandLineUtils.executeCommandLineAsCallable() can hang forever on some JVMs because the StreamPumper threads are blocked in BufferedReader.readLine() on the process's output streams, which never reach EOF.

Fixes #270

@elharo elharo added the bug Something isn't working label Jul 1, 2026
@elharo elharo self-assigned this Jul 1, 2026
@elharo elharo requested a review from Tibor17 July 1, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MSHARED-688] [WORKAROUND] executeCommandLineAsCallable hangs reading open std/out on exited Process as JVM bug

1 participant