commit 11e8afb37cea3d4b951165f382eeee36a653978f (tree)
parent 57f44eb2bd17fc0c4e9d09b8c8621867f784d2f0
Author: Josh Wolfe <thejoshwolfe@gmail.com>
Date: Wed, 28 Nov 2018 18:33:55 -0500
fix child_process piped streams not getting closed
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/std/os/child_process.zig b/std/os/child_process.zig
@@ -390,6 +390,19 @@ pub const ChildProcess = struct {
setUpChildIo(self.stdout_behavior, stdout_pipe[1], posix.STDOUT_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err);
setUpChildIo(self.stderr_behavior, stderr_pipe[1], posix.STDERR_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err);
+ if (self.stdin_behavior == StdIo.Pipe) {
+ os.close(stdin_pipe[0]);
+ os.close(stdin_pipe[1]);
+ }
+ if (self.stdout_behavior == StdIo.Pipe) {
+ os.close(stdout_pipe[0]);
+ os.close(stdout_pipe[1]);
+ }
+ if (self.stderr_behavior == StdIo.Pipe) {
+ os.close(stderr_pipe[0]);
+ os.close(stderr_pipe[1]);
+ }
+
if (self.cwd) |cwd| {
os.changeCurDir(self.allocator, cwd) catch |err| forkChildErrReport(err_pipe[1], err);
}