mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 00:26:57 +00:00
std.ChildProcess: fix max_output_bytes handling
The previous logic had a false positive of returning an error when in fact the maximum number of output bytes had not been exceeded.
This commit is contained in:
parent
0b46c27333
commit
8078d8cd3f
@ -212,16 +212,18 @@ pub const ChildProcess = struct {
|
||||
if (poll_fds[0].revents & os.POLLIN != 0) {
|
||||
// stdout is ready.
|
||||
const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes);
|
||||
if (new_capacity == stdout.capacity) return error.StdoutStreamTooLong;
|
||||
try stdout.ensureCapacity(new_capacity);
|
||||
stdout.items.len += try os.read(poll_fds[0].fd, stdout.unusedCapacitySlice());
|
||||
const buf = stdout.unusedCapacitySlice();
|
||||
if (buf.len == 0) return error.StdoutStreamTooLong;
|
||||
stdout.items.len += try os.read(poll_fds[0].fd, buf);
|
||||
}
|
||||
if (poll_fds[1].revents & os.POLLIN != 0) {
|
||||
// stderr is ready.
|
||||
const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes);
|
||||
if (new_capacity == stderr.capacity) return error.StderrStreamTooLong;
|
||||
try stderr.ensureCapacity(new_capacity);
|
||||
stderr.items.len += try os.read(poll_fds[1].fd, stderr.unusedCapacitySlice());
|
||||
const buf = stderr.unusedCapacitySlice();
|
||||
if (buf.len == 0) return error.StderrStreamTooLong;
|
||||
stderr.items.len += try os.read(poll_fds[1].fd, buf);
|
||||
}
|
||||
|
||||
// Exclude the fds that signaled an error.
|
||||
|
Loading…
Reference in New Issue
Block a user