[][src]Crate process_control

This crate allows running a process with a timeout, with the option to terminate it automatically afterward. The latter is surprisingly difficult to achieve on Unix, since process identifiers can be arbitrarily reassigned when no longer used. Thus, it would be extremely easy to inadvertently terminate an unexpected process. This crate protects against that possibility.

Methods for creating timeouts are available on ChildExt, which is implemented for Child. They each return a builder of options to configure how the timeout should be applied.


All traits are sealed, meaning that they can only be implemented by this crate. Otherwise, backward compatibility would be more difficult to maintain for new features.

Comparable Crates

  • wait-timeout - Made for a related purpose but does not provide the same functionality. Processes cannot be terminated automatically, and there is no counterpart of Child::wait_with_output to read output while setting a timeout. This crate aims to fill in those gaps and simplify the implementation, now that Receiver::recv_timeout exists.


use std::io;
use std::process::Command;
use std::process::Stdio;
use std::time::Duration;

use process_control::ChildExt;
use process_control::Timeout;

let process = Command::new("echo")

let output = process
    .ok_or_else(|| {
        io::Error::new(io::ErrorKind::TimedOut, "Process timed out")
assert_eq!(b"hello", &output.stdout[..5]);



Equivalent to ExitStatus in the standard library but allows for greater accuracy.


Equivalent to Output in the standard library but holds an instance of ExitStatus from this crate.


A wrapper that stores enough information to terminate a process.



Extensions to Child for easily terminating processes.


A temporary wrapper for a process timeout.