| ... | @@ -593,9 +593,9 @@ pub const ChildProcess = struct { | ... | @@ -593,9 +593,9 @@ pub const ChildProcess = struct { |
| 593 | var actions = try os.posix_spawn.Actions.init(); | 593 | var actions = try os.posix_spawn.Actions.init(); |
| 594 | defer actions.deinit(); | 594 | defer actions.deinit(); |
| 595 | | 595 | |
| 596 | try setUpChildIoPosixSpawn(self.stdin_behavior, &actions, stdin_pipe[0], os.STDIN_FILENO, dev_null_fd); | 596 | try setUpChildIoPosixSpawn(self.stdin_behavior, &actions, stdin_pipe, os.STDIN_FILENO, dev_null_fd); |
| 597 | try setUpChildIoPosixSpawn(self.stdout_behavior, &actions, stdout_pipe[1], os.STDOUT_FILENO, dev_null_fd); | 597 | try setUpChildIoPosixSpawn(self.stdout_behavior, &actions, stdout_pipe, os.STDOUT_FILENO, dev_null_fd); |
| 598 | try setUpChildIoPosixSpawn(self.stderr_behavior, &actions, stderr_pipe[1], os.STDERR_FILENO, dev_null_fd); | 598 | try setUpChildIoPosixSpawn(self.stderr_behavior, &actions, stderr_pipe, os.STDERR_FILENO, dev_null_fd); |
| 599 | | 599 | |
| 600 | if (self.cwd_dir) |cwd| { | 600 | if (self.cwd_dir) |cwd| { |
| 601 | try actions.fchdir(cwd.fd); | 601 | try actions.fchdir(cwd.fd); |
| ... | @@ -650,12 +650,16 @@ pub const ChildProcess = struct { | ... | @@ -650,12 +650,16 @@ pub const ChildProcess = struct { |
| 650 | fn setUpChildIoPosixSpawn( | 650 | fn setUpChildIoPosixSpawn( |
| 651 | stdio: StdIo, | 651 | stdio: StdIo, |
| 652 | actions: *os.posix_spawn.Actions, | 652 | actions: *os.posix_spawn.Actions, |
| 653 | pipe_fd: i32, | 653 | pipe_fd: [2]i32, |
| 654 | std_fileno: i32, | 654 | std_fileno: i32, |
| 655 | dev_null_fd: i32, | 655 | dev_null_fd: i32, |
| 656 | ) !void { | 656 | ) !void { |
| 657 | switch (stdio) { | 657 | switch (stdio) { |
| 658 | .Pipe => try actions.dup2(pipe_fd, std_fileno), | 658 | .Pipe => { |
| | 659 | const idx: usize = if (std_fileno == 0) 0 else 1; |
| | 660 | try actions.dup2(pipe_fd[idx], std_fileno); |
| | 661 | try actions.close(pipe_fd[1-idx]); |
| | 662 | }, |
| 659 | .Close => try actions.close(std_fileno), | 663 | .Close => try actions.close(std_fileno), |
| 660 | .Inherit => {}, | 664 | .Inherit => {}, |
| 661 | .Ignore => try actions.dup2(dev_null_fd, std_fileno), | 665 | .Ignore => try actions.dup2(dev_null_fd, std_fileno), |