Waits up to timeout_ms for the child's output or error and reads what arrived into the two buffers: (success, output_bytes, error_bytes).
read_from_process :: (
process: *Process,
output_buffer: [] u8,
error_buffer: [] u8,
timeout_ms := -1
) -> (success: bool, output_bytes: int, error_bytes: int)
A timeout_ms of 0 only looks, and -1 (the default) waits for ever. Nothing arriving in time is a success with 0 and 0.
Each call reads at most one buffer's worth from each pipe, so loop until process.output.eof and process.error.eof for all of
it, and give the loop a time limit of its own.
Parameters
- process: *Process
- output_buffer: [] u8
- error_buffer: [] u8
- timeout_ms := -1
Returns
- success: bool
- output_bytes: int
- error_bytes: int
process: Process;
assert(create_process(*process, "cmd.exe", "/c", "echo hi", capture_and_return_output = true));
defer deinit(*process);
output: [64] u8;
errors: [64] u8;
ok, out_count, _ := read_from_process(*process, output, errors, 5000);
assert(ok && out_count > 0);Doesn't run in the browser (only on windows).