[−][src]Trait process_control::Terminator
Extensions to Child for easily killing processes.
For more information, see the module-level documentation.
Required methods
#[must_use]
fn terminator(&self) -> ProcessTerminator
Creates an instance of ProcessTerminator for this process.
Examples
use std::process::Command; use process_control::Terminator; let process = Command::new("echo").spawn()?; let process_terminator = process.terminator();
fn wait_with_timeout(
self,
time_limit: Duration
) -> IoResult<Option<(ExitStatus, Child)>>
self,
time_limit: Duration
) -> IoResult<Option<(ExitStatus, Child)>>
A convenience method for calling Child::wait with a timeout.
If the time limit expires before that method returns,
ProcessTerminator::terminate will be called in another thread,
without waiting for the process to finish. Ok(None) will be returned
in that case.
As the Child must be consumed by this method, it is returned if the
process finishes. The instance would be required to subsequently access
Child::stdout or other fields. That pattern is unique to this
method; wait_for_output_with_timeout captures all output, so the
instance should be unnecessary afterward.
Examples
use std::process::Command; use std::time::Duration; use process_control::Terminator; let process = Command::new("echo").spawn()?; match process.wait_with_timeout(Duration::from_secs(1))? { Some((exit_status, _)) => assert!(exit_status.success()), None => panic!("process timed out"), }
fn wait_for_output_with_timeout(
self,
time_limit: Duration
) -> IoResult<Option<Output>>
self,
time_limit: Duration
) -> IoResult<Option<Output>>
A convenience method for calling Child::wait_with_output with a
timeout.
For more information, see wait_with_timeout.
Implementations on Foreign Types
impl Terminator for Child[src]
fn terminator(&self) -> ProcessTerminator[src]
fn wait_with_timeout(
self,
time_limit: Duration
) -> IoResult<Option<(ExitStatus, Child)>>[src]
self,
time_limit: Duration
) -> IoResult<Option<(ExitStatus, Child)>>
fn wait_for_output_with_timeout(
self,
time_limit: Duration
) -> IoResult<Option<Output>>[src]
self,
time_limit: Duration
) -> IoResult<Option<Output>>