Skip to main content

run_with_timeout

Function run_with_timeout 

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

Run a single command with a hard SIGKILL on timeout.

Watchdog is a one-shot thread parked on a recv_timeout against an mpsc channel; on timeout it calls libc::kill(pid, SIGKILL). On success the main thread sends a completion message which causes the watchdog to exit harmlessly.

ยงErrors

Returns Err only if spawn() itself fails. Subprocess non-zero exits + timeouts are surfaced through the CapturedOutput.