Skip to main content

run_capture_with_timeout

Function run_capture_with_timeout 

Source
pub async fn run_capture_with_timeout(
    cmd: Command,
    timeout: Duration,
    label: &str,
    on_timeout: impl FnOnce() -> Error,
) -> Result<Output>
Expand description

Spawn cmd under the standard rails with piped output, drain stdout+stderr concurrently (a high-output child cannot deadlock on a full pipe buffer), and enforce timeout.

On timeout the wait-future is dropped (so kill_on_drop reaps the direct child) and, on unix, the whole process group is SIGKILLed so grandchildren die too; the returned error is on_timeout(). label names the tool in the spawn/wait error messages.