pub trait ChildExt<'a>: Sealed {
    type ExitStatusControl: 'a + Control<Result = ExitStatus> + Debug;
    type OutputControl: Control<Result = Output> + Debug;

    // Required methods
    fn terminate_if_running(&mut self) -> Result<()>;
    fn controlled(&'a mut self) -> Self::ExitStatusControl;
    fn controlled_with_output(self) -> Self::OutputControl;
}
Expand description

Extensions to Child for easily terminating processes.

For more information, see the module-level documentation.

Required Associated Types§

source

type ExitStatusControl: 'a + Control<Result = ExitStatus> + Debug

The type returned by controlled.

source

type OutputControl: Control<Result = Output> + Debug

The type returned by controlled_with_output.

Required Methods§

source

fn terminate_if_running(&mut self) -> Result<()>

👎Deprecated since 4.1.0: use Child::kill instead

Equivalent to Child::kill but ignores errors when the process is no longer running.

Windows and Unix errors are inconsistent when terminating processes. This method unifies them by simulating Unix behavior on Windows.

This method is no longer necessary, as the standard library has been updated to perform the same unification.

source

fn controlled(&'a mut self) -> Self::ExitStatusControl

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

This method parallels Child::wait but allows setting limits on the process.

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

use process_control::ChildExt;
use process_control::Control;

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

fn controlled_with_output(self) -> Self::OutputControl

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

This method parallels Child::wait_with_output but allows setting limits on the process.

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

use process_control::ChildExt;
use process_control::Control;

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

Implementations on Foreign Types§

source§

impl<'a> ChildExt<'a> for Child

§

type ExitStatusControl = Buffer<&'a mut Child>

§

type OutputControl = Buffer<Child>

source§

fn terminate_if_running(&mut self) -> Result<()>

👎Deprecated since 4.1.0: use Child::kill instead
source§

fn controlled(&'a mut self) -> Self::ExitStatusControl

source§

fn controlled_with_output(self) -> Self::OutputControl

Implementors§