From 8a9bf8b487393fb01c915e1629d752f6b89237e5 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 26 Mar 2024 14:51:23 -0400 Subject: [PATCH] fork-exec: Don't double-close parent fds Previously the fork/exec backend would attempt to close stdin, et al. on process spawn failure. This result in spurious `close` failures due to `runInteractiveProcess` doing the same. Consequently, the cause of the failure would be confusingly mis-identified. Fixes #306. --- cbits/posix/fork_exec.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cbits/posix/fork_exec.c b/cbits/posix/fork_exec.c index 061904ce..f1ce9cf0 100644 --- a/cbits/posix/fork_exec.c +++ b/cbits/posix/fork_exec.c @@ -335,16 +335,8 @@ do_spawn_fork (char *const args[], // our responsibility to reap here as nobody else can. waitpid(pid, NULL, 0); - // Already closed child ends above - if (stdInHdl->behavior == STD_HANDLE_USE_PIPE) { - close(stdInHdl->use_pipe.parent_end); - } - if (stdOutHdl->behavior == STD_HANDLE_USE_PIPE) { - close(stdOutHdl->use_pipe.parent_end); - } - if (stdErrHdl->behavior == STD_HANDLE_USE_PIPE) { - close(stdErrHdl->use_pipe.parent_end); - } + // No need to close stdin, et al. here as runInteractiveProcess will + // handle this. See #306. pid = -1; }