Trait process_control::ChildExt[][src]

pub trait ChildExt<'a>: Sealed {
    type ExitStatusTimeout: 'a + Timeout<Result = ExitStatus>;
    type OutputTimeout: Timeout<Result = Output>;
    fn terminator(&self) -> Result<Terminator>;
fn with_timeout(
        &'a mut self,
        time_limit: Duration
    ) -> Self::ExitStatusTimeout;
fn with_output_timeout(self, time_limit: Duration) -> Self::OutputTimeout; }
Expand description

Extensions to Child for easily terminating processes.

For more information, see the module-level documentation.

Associated Types

The type returned by with_timeout.

The type returned by with_output_timeout.

Required methods

Creates an instance of Terminator for this process.

Examples

use std::process::Command;

use process_control::ChildExt;

let process = Command::new("echo").spawn()?;
let terminator = process.terminator()?;

Creates an instance of Timeout that yields ExitStatus for this process.

This method parallels Child::wait when the process must finish within a time limit.

Examples

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

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

let exit_status = Command::new("echo")
    .spawn()?
    .with_timeout(Duration::from_secs(1))
    .terminating()
    .wait()?
    .expect("process timed out");
assert!(exit_status.success());

Creates an instance of Timeout that yields Output for this process.

This method parallels Child::wait_with_output when the process must finish within a time limit.

Examples

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

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

let output = Command::new("echo")
    .spawn()?
    .with_output_timeout(Duration::from_secs(1))
    .terminating()
    .wait()?
    .expect("process timed out");
assert!(output.status.success());

Implementations on Foreign Types

Implementors