| ... | @@ -212,16 +212,18 @@ pub const ChildProcess = struct { | ... | @@ -212,16 +212,18 @@ pub const ChildProcess = struct { |
| 212 | if (poll_fds[0].revents & os.POLLIN != 0) { | 212 | if (poll_fds[0].revents & os.POLLIN != 0) { |
| 213 | // stdout is ready. | 213 | // stdout is ready. |
| 214 | const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes); | 214 | const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes); |
| 215 | if (new_capacity == stdout.capacity) return error.StdoutStreamTooLong; | | |
| 216 | try stdout.ensureCapacity(new_capacity); | 215 | try stdout.ensureCapacity(new_capacity); |
| 217 | stdout.items.len += try os.read(poll_fds[0].fd, stdout.unusedCapacitySlice()); | 216 | const buf = stdout.unusedCapacitySlice(); |
| | 217 | if (buf.len == 0) return error.StdoutStreamTooLong; |
| | 218 | stdout.items.len += try os.read(poll_fds[0].fd, buf); |
| 218 | } | 219 | } |
| 219 | if (poll_fds[1].revents & os.POLLIN != 0) { | 220 | if (poll_fds[1].revents & os.POLLIN != 0) { |
| 220 | // stderr is ready. | 221 | // stderr is ready. |
| 221 | const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes); | 222 | const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes); |
| 222 | if (new_capacity == stderr.capacity) return error.StderrStreamTooLong; | | |
| 223 | try stderr.ensureCapacity(new_capacity); | 223 | try stderr.ensureCapacity(new_capacity); |
| 224 | stderr.items.len += try os.read(poll_fds[1].fd, stderr.unusedCapacitySlice()); | 224 | const buf = stderr.unusedCapacitySlice(); |
| | 225 | if (buf.len == 0) return error.StderrStreamTooLong; |
| | 226 | stderr.items.len += try os.read(poll_fds[1].fd, buf); |
| 225 | } | 227 | } |
| 226 | | 228 | |
| 227 | // Exclude the fds that signaled an error. | 229 | // Exclude the fds that signaled an error. |