Skip to main content

UnixChild

Struct UnixChild 

Source
pub struct UnixChild {
    pub stdin: Option<ChildStdin>,
    pub stdout: Option<ChildStdout>,
    pub stderr: Option<ChildStderr>,
    /* private fields */
}
Expand description

A spawned Unix child. The same API as Windows’ WindowsChild: public stdio fields, id, try_wait, wait and kill. It does not expose the std Child, because a std reap the crate cannot see would make later group signals unsafe (see the module documentation).

Obtained through OwnedChild::child, which holds the shared lock while the guard lives. wait through the guard therefore holds that lock until the child has exited, and every other thread’s access to the same child (a bounded wait on a clone, kill, terminate_tree, Drop) waits behind it, as std::process::Child::wait through the guard did in 0.3.3. Prefer OwnedChild::wait, wait_timeout or ProcessHandle::wait, which release the lock between looks.

Fields§

§stdin: Option<ChildStdin>§stdout: Option<ChildStdout>§stderr: Option<ChildStderr>

Implementations§

Source§

impl UnixChild

Source

pub fn id(&self) -> u32

Source

pub fn try_wait(&mut self) -> Result<Option<ExitStatus>>

Non-blocking. A Some result means the leader has been reaped, and ends group signalling for this child.

Source

pub fn wait(&mut self) -> Result<ExitStatus>

Closes stdin as std does, then waits until the leader is reaped. The reap itself is only ever a non-blocking waitpid(WNOHANG) between sleeps, but this method cannot release the lock: when it is reached through the OwnedChild::child() guard the caller holds it for the whole wait, so other threads’ waits, kills and drops on the same child queue behind it (as with std::process::Child::wait in 0.3.3). Use OwnedChild::wait or ProcessHandle::wait where that matters.

Source

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

SIGKILL to the leader alone, only while it is unreaped. Nothing is sent, and Ok is returned, once it has been reaped.

Trait Implementations§

Source§

impl Debug for UnixChild

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.