[−][src]Struct torut::utils::AutoKillChild
AutoKillChild is kind of bag which contains Child
.
It makes it automatically commit suicide after it gets dropped.
It's designed to be used with tor running in rust application. AKC guarantees killing tor application on exit. Note: It ignores process killing error in Drop.
Implementations
impl AutoKillChild
[src]
pub fn new(c: Child) -> Self
[src]
pub fn into_inner(self) -> Child
[src]
into_inner takes child from AutoKillChild. It prevents child from dying automatically after it's dropped.
Methods from Deref<Target = Child>
pub fn kill(&mut self) -> Result<(), Error>
1.0.0[src]
Forces the child process to exit. If the child has already exited, an InvalidInput
error is returned.
The mapping to ErrorKind
s is not part of the compatibility contract of the function,
especially the Other
kind might change to more specific kinds in the future.
This is equivalent to sending a SIGKILL on Unix platforms.
Examples
Basic usage:
use std::process::Command; let mut command = Command::new("yes"); if let Ok(mut child) = command.spawn() { child.kill().expect("command wasn't running"); } else { println!("yes command didn't start"); }
pub fn id(&self) -> u32
1.3.0[src]
Returns the OS-assigned process identifier associated with this child.
Examples
Basic usage:
use std::process::Command; let mut command = Command::new("ls"); if let Ok(child) = command.spawn() { println!("Child's ID is {}", child.id()); } else { println!("ls command didn't start"); }
pub fn wait(&mut self) -> Result<ExitStatus, Error>
1.0.0[src]
Waits for the child to exit completely, returning the status that it exited with. This function will continue to have the same return value after it has been called at least once.
The stdin handle to the child process, if any, will be closed before waiting. This helps avoid deadlock: it ensures that the child does not block waiting for input from the parent, while the parent waits for the child to exit.
Examples
Basic usage:
use std::process::Command; let mut command = Command::new("ls"); if let Ok(mut child) = command.spawn() { child.wait().expect("command wasn't running"); println!("Child has finished its execution!"); } else { println!("ls command didn't start"); }
pub fn try_wait(&mut self) -> Result<Option<ExitStatus>, Error>
1.18.0[src]
Attempts to collect the exit status of the child if it has already exited.
This function will not block the calling thread and will only check to see if the child process has exited or not. If the child has exited then on Unix the process ID is reaped. This function is guaranteed to repeatedly return a successful exit status so long as the child has already exited.
If the child has exited, then Ok(Some(status))
is returned. If the
exit status is not available at this time then Ok(None)
is returned.
If an error occurs, then that error is returned.
Note that unlike wait
, this function will not attempt to drop stdin.
Examples
Basic usage:
use std::process::Command; let mut child = Command::new("ls").spawn().unwrap(); match child.try_wait() { Ok(Some(status)) => println!("exited with: {}", status), Ok(None) => { println!("status not ready yet, let's really wait"); let res = child.wait(); println!("result: {:?}", res); } Err(e) => println!("error attempting to wait: {}", e), }
Trait Implementations
impl Deref for AutoKillChild
[src]
type Target = Child
The resulting type after dereferencing.
pub fn deref(&self) -> &Self::Target
[src]
impl DerefMut for AutoKillChild
[src]
impl Drop for AutoKillChild
[src]
impl From<Child> for AutoKillChild
[src]
Auto Trait Implementations
impl RefUnwindSafe for AutoKillChild
impl Send for AutoKillChild
impl Sync for AutoKillChild
impl Unpin for AutoKillChild
impl UnwindSafe for AutoKillChild
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,