Skip to main content

command_output_with_timeout

Function command_output_with_timeout 

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

Run a [Command] with a timeout. On timeout the watchdog sends SIGTERM, waits KILL_GRACE_PERIOD for the child to exit cleanly, then escalates to SIGKILL (Unix) / TerminateProcess retry (Windows).

Caveat: if the child forks descendants that inherit its stdout/stderr pipes (e.g. a shell wrapper spawning a long-running grandchild), SIGKILL on the immediate child will not close those pipes — wait_with_output will block on them until the grandchild also dies. Production callers should invoke the target binary directly rather than via a shell wrapper.