Skip to content

Commit

Permalink
fork-exec: Don't double-close parent fds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bgamari committed Mar 26, 2024
1 parent a590acd commit 8a9bf8b
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions cbits/posix/fork_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8a9bf8b

Please sign in to comment.