Skip to main content

output_with_timeout

Function output_with_timeout 

Source
pub fn output_with_timeout(
    cmd: &mut Command,
    timeout: Duration,
) -> Result<Output>
Expand description

Run cmd to completion with a deadline, capturing stdout/stderr — a Command::output() that cannot hang. On expiry the child is killed and (bounded-best-effort) reaped, and ErrorKind::TimedOut comes back. stdin is null.

Pipes are drained on background threads, so a child that writes more than a pipe buffer’s worth can’t deadlock against the wait loop.