Skip to main content

ScopedChild

Struct ScopedChild 

Source
pub struct ScopedChild { /* private fields */ }
Expand description

RAII handle wrapping a spawned Child with registry tracking.

Implementations§

Source§

impl ScopedChild

Source

pub fn spawn(command: &mut Command) -> Result<Self>

Spawn the command and register the resulting child’s PID.

Source

pub fn spawn_process_tree(command: &mut Command) -> Result<Self>

Spawn a subprocess wrapper in a dedicated process tree and register the tree for process-wide signal cleanup.

Source

pub fn process_tree_terminator(&self) -> Option<ProcessTreeTerminator>

Return a cloneable handle that terminates the owned tree, or the direct child when it inherited a tree from a Fallow parent.

Source

pub fn id(&self) -> u32

OS-level process id of the underlying child. Returns 0 if the child has been consumed.

Source

pub fn take_stdin(&mut self) -> Option<ChildStdin>

Take the child’s stdin handle, if it was piped. Same semantics as Child::stdin.take(). Returns None if stdin was not piped or the child has been consumed.

Source

pub fn take_stdout(&mut self) -> Option<ChildStdout>

Take the child’s stdout handle, if it was piped. Same semantics as Child::stdout.take(). Returns None if stdout was not piped or the child has been consumed. Used by long-lived readers (e.g. the audit base-file cat-file --batch reader) that drive both pipes while leaving the wrapper owning the child for registry tracking and the terminal wait.

Source

pub fn take_stderr(&mut self) -> Option<ChildStderr>

Take the child’s stderr handle, if it was piped. Same semantics as Child::stderr.take().

Source

pub fn wait_with_output(self) -> Result<Output>

Consume self and wait for the child to exit, collecting stdout and stderr. The signal handler may have already killed the child via the registered termination target; in that case wait returns normally with a non-zero status.

Source

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

Wait for the child to exit, returning the status. Same signal-cleanup semantics as wait_with_output.

Trait Implementations§

Source§

impl Drop for ScopedChild

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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, <T as TryFrom<U>>::Error>

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.