Function collectOutput [src]

Collect the output from the process's stdout and stderr. Will return once all output has been collected. This does not mean that the process has ended. wait should still be called to wait for and clean up the process. The process must be started with stdout_behavior and stderr_behavior == .Pipe

Prototype

pub fn collectOutput( child: ChildProcess, allocator: Allocator, stdout: *std.ArrayListUnmanaged(u8), stderr: *std.ArrayListUnmanaged(u8), max_output_bytes: usize, ) !void

Parameters

child: ChildProcessallocator: AllocatorUsed for stdout and stderr. stdout: *std.ArrayListUnmanaged(u8)stderr: *std.ArrayListUnmanaged(u8)max_output_bytes: usize

Source

pub fn collectOutput( child: ChildProcess, /// Used for `stdout` and `stderr`. allocator: Allocator, stdout: *std.ArrayListUnmanaged(u8), stderr: *std.ArrayListUnmanaged(u8), max_output_bytes: usize, ) !void { assert(child.stdout_behavior == .Pipe); assert(child.stderr_behavior == .Pipe); var poller = std.io.poll(allocator, enum { stdout, stderr }, .{ .stdout = child.stdout.?, .stderr = child.stderr.?, }); defer poller.deinit(); while (try poller.poll()) { if (poller.fifo(.stdout).count > max_output_bytes) return error.StdoutStreamTooLong; if (poller.fifo(.stderr).count > max_output_bytes) return error.StderrStreamTooLong; } try writeFifoDataToArrayList(allocator, stdout, poller.fifo(.stdout)); try writeFifoDataToArrayList(allocator, stderr, poller.fifo(.stderr)); }