[][src]Struct two_rusty_forks::ChildWrapper

pub struct ChildWrapper { /* fields omitted */ }

Wraps a std::process::Child to coordinate state between std and wait_timeout.

This is necessary because the completion of a call to wait_timeout::ChildExt::wait_timeout leaves the Child in an inconsistent state, as it does not know the child has exited, and on Unix may end up referencing another process.

Documentation for this struct's methods is largely copied from the Rust std docs.

Implementations

impl ChildWrapper[src]

pub fn inner(&self) -> &Child[src]

Return a reference to the inner std::process::Child.

Use care on the returned object, as it does not necessarily reference the correct process unless you know the child process has not exited and no wait calls have succeeded.

pub fn inner_mut(&mut self) -> &mut Child[src]

Return a mutable reference to the inner std::process::Child.

Use care on the returned object, as it does not necessarily reference the correct process unless you know the child process has not exited and no wait calls have succeeded.

pub fn kill(&mut self) -> Result<()>[src]

Forces the child to exit. This is equivalent to sending a SIGKILL on unix platforms.

If the process has already been reaped by this handle, returns a NotFound error.

pub fn id(&self) -> u32[src]

Returns the OS-assigned processor identifier associated with this child.

This succeeds even if the child has already been reaped. In this case, the process id may reference no process at all or even an unrelated process.

pub fn wait(&mut self) -> Result<ExitStatusWrapper>[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.

If the child process has already been reaped, returns its exit status without blocking.

pub fn try_wait(&mut self) -> Result<Option<ExitStatusWrapper>>[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 advisorily 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.

pub fn wait_with_output(self) -> Result<Output>[src]

Simultaneously waits for the child to exit and collect all remaining output on the stdout/stderr handles, returning an Output instance.

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.

By default, stdin, stdout and stderr are inherited from the parent. (In the context of rusty_fork, they are by default redirected to a file.) In order to capture the output into this Result<Output> it is necessary to create new pipes between parent and child. Use stdout(Stdio::piped()) or stderr(Stdio::piped()), respectively.

If the process has already been reaped, returns a NotFound error.

pub fn wait_timeout(
    &mut self,
    dur: Duration
) -> Result<Option<ExitStatusWrapper>>
[src]

Wait for the child to exit, but only up to the given maximum duration.

If the process has already been reaped, returns its exit status immediately. Otherwise, if the process terminates within the duration, returns Ok(Sone(..)), or Ok(None) otherwise.

This is only present if the "timeout" feature is enabled.

Trait Implementations

impl Debug for ChildWrapper[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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,