JDK-8377907 added file actions to spawnChild() without cleanup. This patch destroys them at both adddup2 error exits and immediately after posix_spawn().
The cleanup helper preserves errno so it does not change the IOException diagnostics in forkAndExec(). ### Testing macOS 26.2/aarch64, release build. Before: JDK 27+35-2325. After: commit 1077a0ab5ec. make exploded-test TEST="jtreg:test/jdk/java/lang/ProcessBuilder": 26 passed, 0 failed, 13 not run. Manual checks used MallocStackLogging=1 and `leaks --fullStacks <PID>`. Counts sum all ROOT LEAK groups labeled realloc in _posix_spawn_file_actions_grow. The successful-launch Before result and reproducer are attached to [JDK-8394402](https://bugs.openjdk.org/browse/JDK-8394402). | Scenario | Before | After | |---|---:|---:| | 110 successful launches | 110 | 0 | | 50 first-adddup2 failures | 50 | 0 | | 50 fifth-adddup2 failures | 50 | 0 | The adddup2 failures used a DYLD_INSERT_LIBRARIES interposer returning EBADF for newfd=0 or newfd=3. No automated regression test is included: NMT does not track these libc allocations, and the manual checks use macOS tools. [JDK-8311645](https://bugs.openjdk.org/browse/JDK-8311645) used noreg-hard for a leak in the same function. GitHub Actions: Linux x64 builds and tier1 passed. Native leaks were not measured on Linux or AIX. --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - 8394402: (process) Native memory leak in ProcessBuilder POSIX_SPAWN after JDK-8377907 Changes: https://git.openjdk.org/jdk/pull/33360/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33360&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8394402 Stats: 12 lines in 1 file changed: 12 ins; 0 del; 0 mod Patch: https://git.openjdk.org/jdk/pull/33360.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33360/head:pull/33360 PR: https://git.openjdk.org/jdk/pull/33360
