Process module

read_pipe

procedureSource

Reads what is available now from one pipe of a process into buffer, and returns (success, bytes_read). 0 bytes with success means nothing is there yet, or the end: check pipe.eof. It fails with a closed pipe or an empty buffer. Use read_from_process to wait for data on both pipes.

read_pipe :: (
    pipe: *Process.Pipe,
    buffer: [] u8
) -> (success: bool, bytes_read: int)

Parameters

pipe: *Process.Pipe
buffer: [] u8

Returns

success: bool
bytes_read: int
Example
process: Process;
assert(create_process(*process, "cmd.exe", "/c", "echo hi", capture_and_return_output = true));
defer deinit(*process);
get_process_result(*process, 5000);

buffer: [64] u8;
ok, count := read_pipe(*process.output, buffer);
assert(ok && count > 0);

Doesn't run in the browser (only on windows).

See also