RFR: 8291986: ProcessBuilder.redirectErrorStream(true) leaves error stream available

Roger Riggs rriggs at openjdk.org
Fri Jan 9 17:57:00 UTC 2026


On Linux and Mac, when a process is started, pipes are created to communicate with the child.
In the case where the stderr is redirected to stdout using `ProcessBuilder.redirectErrorStream()`, the pipe is not needed and should not be created.

Added a test to check pipe creation when spawning with and without `redirectErrorStream(t/f)`. 
Rewrote the extraction of pipes to use `lsof` available on Mac and Linux. (previously used Linux /proc/pid/fd/...)
Converted PipelineLeaksFD test to JUnit.

-------------

Commit messages:
 - 8291986: ProcessBuilder.redirectErrorStream(true) leaves error stream available

Changes: https://git.openjdk.org/jdk/pull/29143/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29143&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8291986
  Stats: 180 lines in 3 files changed: 132 ins; 2 del; 46 mod
  Patch: https://git.openjdk.org/jdk/pull/29143.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29143/head:pull/29143

PR: https://git.openjdk.org/jdk/pull/29143


More information about the core-libs-dev mailing list