| ... | @@ -65,6 +65,7 @@ pub const ChildProcess = struct { | ... | @@ -65,6 +65,7 @@ pub const ChildProcess = struct { |
| 65 | defer restore_SIGCHLD(); | 65 | defer restore_SIGCHLD(); |
| 66 | | 66 | |
| 67 | if (self.term) |term| { | 67 | if (self.term) |term| { |
| | 68 | self.cleanupStreams(); |
| 68 | return term; | 69 | return term; |
| 69 | } | 70 | } |
| 70 | const ret = posix.kill(self.pid, posix.SIGTERM); | 71 | const ret = posix.kill(self.pid, posix.SIGTERM); |
| ... | @@ -87,6 +88,7 @@ pub const ChildProcess = struct { | ... | @@ -87,6 +88,7 @@ pub const ChildProcess = struct { |
| 87 | defer restore_SIGCHLD(); | 88 | defer restore_SIGCHLD(); |
| 88 | | 89 | |
| 89 | if (self.term) |term| { | 90 | if (self.term) |term| { |
| | 91 | self.cleanupStreams(); |
| 90 | return term; | 92 | return term; |
| 91 | } | 93 | } |
| 92 | | 94 | |
| ... | @@ -119,9 +121,9 @@ pub const ChildProcess = struct { | ... | @@ -119,9 +121,9 @@ pub const ChildProcess = struct { |
| 119 | } | 121 | } |
| 120 | | 122 | |
| 121 | fn cleanupStreams(self: &ChildProcess) { | 123 | fn cleanupStreams(self: &ChildProcess) { |
| 122 | if (self.stdin) |stdin| { stdin.close(); self.allocator.free(stdin); } | 124 | if (self.stdin) |stdin| { stdin.close(); self.allocator.free(stdin); self.stdin = null; } |
| 123 | if (self.stdout) |stdout| { stdout.close(); self.allocator.free(stdout); } | 125 | if (self.stdout) |stdout| { stdout.close(); self.allocator.free(stdout); self.stdout = null; } |
| 124 | if (self.stderr) |stderr| { stderr.close(); self.allocator.free(stderr); } | 126 | if (self.stderr) |stderr| { stderr.close(); self.allocator.free(stderr); self.stderr = null; } |
| 125 | } | 127 | } |
| 126 | | 128 | |
| 127 | fn cleanupAfterWait(self: &ChildProcess, status: i32) -> %Term { | 129 | fn cleanupAfterWait(self: &ChildProcess, status: i32) -> %Term { |