Skip to main content

Child

Struct Child 

Source
pub struct Child { /* private fields */ }
Available on crate feature process only.
Expand description

A child process spawned with Command

Implementations§

Source§

impl Child

Source

pub fn wait_nz(self) -> Result<()>

Block the thread and wait for the child to finish, and check if the ExitStatus is 0

Note that currently any error that occurred in input/output tasks are treated as warning and not hard error.

§Blocking

This will block the current thread while trying to join the child. Use co_wait_nz to avoid blocking if in async context.

Source

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

Block the thread and wait for the child to finish, and return its ExitStatus

Note that currently any error that occurred in input/output tasks are treated as warning and not hard error.

§Blocking

This will block the current thread while trying to join the child. Use co_wait to avoid blocking if in async context.

Source

pub async fn co_wait_nz(self) -> Result<()>

Wait for the child asynchronously using the current tokio runtime, and check if the ExitStatus is 0.

Note that currently any error that occurred in input/output tasks are treated as warning and not hard error.

§Panic

Will panic if called outside of a tokio runtime context

Source

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

Wait for the child asynchronously using the current tokio runtime, and return its ExitStatus

Note that currently any error that occurred in input/output tasks are treated as warning and not hard error.

§Panic

Will panic if called outside of a tokio runtime context

Source

pub fn wait_guard(self) -> ChildWaitGuard

Create a wait guard that will automatically wait for the child (and ignore the error) when going out of scope.

Source

pub async fn co_wait_timeout( &mut self, timeout: Duration, ) -> Result<Option<ExitStatus>>

Wait for the child to exit for at least the timeout. Return the exit status if exited

Source

pub fn wait_timeout(&mut self, timeout: Duration) -> Result<Option<ExitStatus>>

Source

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

Kill the child and wait for it to exit asynchronously. Return the exit status

§Panic

Will panic if called outside of a tokio runtime context

Source

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

Kill the child and block the current thread until the child exits. Return the exit status.

§Blocking

This will block the current thread while trying to join the child. Use co_kill to avoid blocking if in async context.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Child

§

impl !UnwindSafe for Child

§

impl Freeze for Child

§

impl Send for Child

§

impl Sync for Child

§

impl Unpin for Child

§

impl UnsafeUnpin for Child

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.