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