| ... | @@ -587,8 +587,8 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { | ... | @@ -587,8 +587,8 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { |
| 587 | if (self.progress_node.index == .none) { | 587 | if (self.progress_node.index == .none) { |
| 588 | break :p .{ -1, -1 }; | 588 | break :p .{ -1, -1 }; |
| 589 | } else { | 589 | } else { |
| 590 | // No CLOEXEC because the child needs access to this file descriptor. | 590 | // We use CLOEXEC for the same reason as in `pipe_flags`. |
| 591 | break :p try posix.pipe2(.{ .NONBLOCK = true }); | 591 | break :p try posix.pipe2(.{ .NONBLOCK = true, .CLOEXEC = true }); |
| 592 | } | 592 | } |
| 593 | }; | 593 | }; |
| 594 | errdefer destroyPipe(prog_pipe); | 594 | errdefer destroyPipe(prog_pipe); |
| ... | @@ -655,11 +655,6 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { | ... | @@ -655,11 +655,6 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { |
| 655 | setUpChildIo(self.stderr_behavior, stderr_pipe[1], posix.STDERR_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err); | 655 | setUpChildIo(self.stderr_behavior, stderr_pipe[1], posix.STDERR_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 656 | if (prog_pipe[1] != -1) posix.dup2(prog_pipe[1], prog_fileno) catch |err| forkChildErrReport(err_pipe[1], err); | 656 | if (prog_pipe[1] != -1) posix.dup2(prog_pipe[1], prog_fileno) catch |err| forkChildErrReport(err_pipe[1], err); |
| 657 | | 657 | |
| 658 | if (prog_pipe[1] != -1) { | | |
| 659 | if (prog_pipe[0] != prog_fileno) posix.close(prog_pipe[0]); | | |
| 660 | if (prog_pipe[1] != prog_fileno) posix.close(prog_pipe[1]); | | |
| 661 | } | | |
| 662 | | | |
| 663 | if (self.cwd_dir) |cwd| { | 658 | if (self.cwd_dir) |cwd| { |
| 664 | posix.fchdir(cwd.fd) catch |err| forkChildErrReport(err_pipe[1], err); | 659 | posix.fchdir(cwd.fd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 665 | } else if (self.cwd) |cwd| { | 660 | } else if (self.cwd) |cwd| { |