execute_with_timeout

Function execute_with_timeout 

Source
pub fn execute_with_timeout(
    binary: &Path,
    args: &[&str],
    timeout: Duration,
) -> Result<String>
Expand description

Execute binary with timeout and default resource limits

This function provides safe execution with the following guarantees:

  • Timeout enforcement (prevents infinite loops)
  • Output capture (stdout and stderr)
  • Graceful cleanup on timeout
  • Resource limits applied (Unix only)

ยงExamples

use cli_testing_specialist::utils::execute_with_timeout;
use std::path::Path;
use std::time::Duration;

// Execute echo with 5 second timeout
let output = execute_with_timeout(
    Path::new("/bin/echo"),
    &["hello", "world"],
    Duration::from_secs(5)
)?;
assert!(output.contains("hello"));