Skip to main content

ChildProcess

Struct ChildProcess 

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

A child process this agent started.

04-subsystem-contracts.md: “local process state is authoritative only for a child process owned by this agent”. That is this type. For a process recovered from the journal after a restart there is no Child and no parent relationship, so ProcessIdentity is the authority instead.

Implementations§

Source§

impl ChildProcess

Source

pub const fn identity(&self) -> &ProcessIdentity

The identity to record in the journal.

Source

pub const fn pid(&self) -> u32

The child’s PID.

Source

pub fn is_running(&mut self) -> Result<bool, ProcessError>

Whether the child is still running.

§Errors

ProcessError::Control when the wait fails.

Source

pub fn try_exit_status(&mut self) -> Result<Option<ExitStatus>, ProcessError>

The child’s exit status if it has already exited, reaping it if so.

§Errors

ProcessError::Control when the wait fails.

Source

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

Blocks until the child exits.

§Errors

ProcessError::Control when the wait fails.

Source

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

Waits up to timeout for the child to exit; None means it is still running when the timeout expires.

§Errors

ProcessError::Control when the wait fails.

Source

pub fn stop(&mut self, grace: Duration) -> Result<ExitStatus, ProcessError>

Asks the child to stop, forcefully if grace expires first.

See ProcessIdentity::terminate for what grace means on each platform. Unlike that method this one has the parent relationship, so it reaps the child and returns its exit status.

§Errors

ProcessError::Control when signalling or waiting fails.

Source

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

Takes the captured standard output, if OutputMode::Capture was set.

Source

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

Takes the captured standard error, if OutputMode::Capture was set.

Source

pub fn program(&self) -> &Path

The program that was launched.

Trait Implementations§

Source§

impl Debug for ChildProcess

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more