[][src]Struct process_control::ProcessTerminator

pub struct ProcessTerminator(_);

A wrapper that stores enough information to terminate a process.

Instances can only be constructed using Terminator::terminator.

Methods

impl ProcessTerminator[src]

pub fn terminate(&self) -> IoResult<()>[src]

Terminates a process as immediately as the operating system allows.

Behavior should be equivalent to calling Child::kill for the same process. The guarantees on the result of that method are also maintained; different ErrorKind variants may be returned in the future for the same type of failure. Allowing these breakages is required to be compatible with the Error type.

Panics

Panics if the operating system gives conflicting indicators of whether the termination signal was accepted.

Examples

use std::io::Result as IoResult;
use std::process::Command;
use std::thread;
use std::thread::JoinHandle;

use process_control::Terminator;

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

let thread: JoinHandle<IoResult<_>> = thread::spawn(move || {
    process.wait()?;
    println!("waited");
    Ok(())
});

// [process.kill] requires a mutable reference.
process_terminator.terminate()?;
thread.join().expect("thread panicked")?;

pub fn terminate_if_necessary(&self) -> IoResult<()>[src]

Terminates a process as immediately as the operating system allows, ignoring errors about the process no longer existing.

For more information, see terminate.

Trait Implementations

impl Debug for ProcessTerminator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.