When `jspawnhelper` was missing on macOS, `spawnChild()` discarded the error code from `posix_spawn()`, and the `IOException` message reported `error: 0 (none)`.
The patch includes the error code from `posix_spawn()` or file-action setup in the `IOException` message. On macOS, it also stops the launch and reports the error code if `posix_spawn_file_actions_addinherit_np()` fails. The old code ignored that return value. On macOS 26.5.1 (AArch64), `MissingJspawnhelper` failed with `error: 0` before the fix and passed after `ProcessBuilder.start()` reported `error: 2` `(ENOENT)`. The ProcessBuilder jtreg suite had 27 passes, 0 failures, and 13 exclusions. make exploded-test TEST=jtreg:test/jdk/java/lang/ProcessBuilder --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - 8396825: (process) Incorrect error code when POSIX_SPAWN fails Changes: https://git.openjdk.org/jdk/pull/33881/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33881&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8396825 Stats: 111 lines in 2 files changed: 96 ins; 2 del; 13 mod Patch: https://git.openjdk.org/jdk/pull/33881.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33881/head:pull/33881 PR: https://git.openjdk.org/jdk/pull/33881
