pub fn run_with_timeout(
command: &str,
args: &[&str],
timeout: Duration,
config: TimeoutConfig,
) -> SysprimsResult<TimeoutOutcome>Expand description
Run a command with timeout.
Spawns the command and waits for it to complete or timeout. If the command
times out, the acquired process group or Job is signaled (when using
GroupByDefault). Cooperative descendants in that containment are targeted;
Unix descendants can still leave a process group later.
§Arguments
command- Command to execute (path or name in PATH)args- Command argumentstimeout- Maximum duration to wait for command completionconfig- Timeout configuration (signal, escalation, grouping)
§Returns
Ok(TimeoutOutcome::Completed { .. })- Command finished within timeoutOk(TimeoutOutcome::TimedOut { .. })- Command was killed due to timeoutErr(SysprimsError)- Failed to spawn or fatal error
§Examples
use std::time::Duration;
use sysprims_timeout::{run_with_timeout, TimeoutConfig};
// Replaces: timeout 300s make build
let result = run_with_timeout(
"make",
&["build"],
Duration::from_secs(300),
TimeoutConfig::default(),
);