RFR: 8233115: Protect ExecuteWithLog from running with redirection without a subshell

Magnus Ihse Bursie ihse at openjdk.org
Thu Sep 4 15:34:00 UTC 2025


When calling ExecuteWithLog with a redirection (using > or, possibly, <), the entire command needs to be executed in a subshell, that is, inside a pair of parentheses. This is the callers obligation to ensure, but we have proven multiple times that this is hard to keep in mind, and we got several cases of race conditions due to missing this.

This PR changes the implementation of ExecuteWithLog so it checks if the command line contains redirection, and automatically add the subshell parentheses in that case. The alternative would have been to always execute in a subshell, but that would have been very expensive on Windows.

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

Commit messages:
 - 8233115: Protect ExecuteWithLog from running with redirection without a subshell

Changes: https://git.openjdk.org/jdk/pull/27096/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27096&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8233115
  Stats: 32 lines in 5 files changed: 7 ins; 5 del; 20 mod
  Patch: https://git.openjdk.org/jdk/pull/27096.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27096/head:pull/27096

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


More information about the build-dev mailing list