| ... | ... | @@ -654,7 +654,6 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { |
| 654 | 654 | setUpChildIo(self.stdin_behavior, stdin_pipe[0], posix.STDIN_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 655 | 655 | setUpChildIo(self.stdout_behavior, stdout_pipe[1], posix.STDOUT_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 656 | 656 | setUpChildIo(self.stderr_behavior, stderr_pipe[1], posix.STDERR_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 657 | | if (prog_pipe[1] != -1) posix.dup2(prog_pipe[1], prog_fileno) catch |err| forkChildErrReport(err_pipe[1], err); |
| 658 | 657 | |
| 659 | 658 | if (self.cwd_dir) |cwd| { |
| 660 | 659 | posix.fchdir(cwd.fd) catch |err| forkChildErrReport(err_pipe[1], err); |
| ... | ... | @@ -662,6 +661,10 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { |
| 662 | 661 | posix.chdir(cwd) catch |err| forkChildErrReport(err_pipe[1], err); |
| 663 | 662 | } |
| 664 | 663 | |
| 664 | // Must happen after fchdir above, the cwd file descriptor might be |
| 665 | // equal to prog_fileno and be clobbered by this dup2 call. |
| 666 | if (prog_pipe[1] != -1) posix.dup2(prog_pipe[1], prog_fileno) catch |err| forkChildErrReport(err_pipe[1], err); |
| 667 | |
| 665 | 668 | if (self.gid) |gid| { |
| 666 | 669 | posix.setregid(gid, gid) catch |err| forkChildErrReport(err_pipe[1], err); |
| 667 | 670 | } |