Skip to main content

DtactChild

Struct DtactChild 

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

A spawned child process.

wait/wait_with_output consume self (ownership transfers into the pool closure, so nothing needs to be shared or locked); kill/id are synchronous since they’re fast, non-blocking syscalls.

Implementations§

Source§

impl DtactChild

Source

pub fn id(&self) -> u32

The OS process ID of the child.

Source

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

Send SIGKILL (Unix) / TerminateProcess (Windows) to the child.

§Errors

Returns an error if the OS kill syscall fails — in practice this is almost always because the process had already exited (the underlying std::process::Child::kill documents this as the common failure case; it is not itself treated as success).

Source

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

Take ownership of the child’s stdin, if it was configured with Stdio::piped(). Can only be taken once.

Source

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

Take ownership of the child’s stdout, if it was configured with Stdio::piped(). Can only be taken once.

Source

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

Take ownership of the child’s stderr, if it was configured with Stdio::piped(). Can only be taken once.

Source

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

Block (on the process pool, not the calling task’s thread) until the child exits.

§Errors

Returns whatever std::process::Child::wait returns — an I/O error if waiting on the OS process handle itself fails (rare; not the same as the child exiting non-zero, which is a normal Ok with a non-zero ExitStatus).

Source

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

Wait for exit and collect stdout/stderr in one shot — the std-library convenience, dispatched to the pool the same way.

§Errors

Same as Self::wait: an I/O error only if waiting on the OS process handle or reading its piped stdout/stderr fails, not for a non-zero exit status.

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 = Infallible

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.