Skip to main content

OwnedChild

Struct OwnedChild 

Source
pub struct OwnedChild { /* private fields */ }

Implementations§

Source§

impl OwnedChild

Source

pub fn id(&self) -> u32

Source

pub fn child(&self) -> MutexGuard<'_, UnixChild>

Borrow child state, including stdio, wait and try_wait. Windows uses a native view with std pipe types for both spawn paths; Unix uses UnixChild, which has the same members and does not expose the std Child. Release this guard before another accessor or exit reader; it holds the shared reap lock.

Unix: a wait or try_wait through the guard that reaps the leader permanently ends process-group signalling for this child, exactly like OwnedChild::wait.

Unix: wait through the guard holds the shared lock until the child has exited, because the guard is the lock. A bounded wait on a ProcessHandle clone, kill, terminate_tree and Drop on other threads queue behind it and can exceed their own deadlines, as with std::process::Child::wait through this accessor in 0.3.3. Wait through OwnedChild::wait/wait_timeout or a ProcessHandle when anything else must stay live meanwhile. (Windows: WindowsChild::wait through the guard blocks in WaitForSingleObject while holding the lock, as in 0.3.3.)

Source

pub fn while_unreaped<R>(&self, act: impl FnOnce(u32) -> R) -> Result<Option<R>>

Runs act with the leader’s pid while the leader is proven to be this child and unreaped, holding the shared lock so no reap can fall between the proof and act. Returns Ok(None) without calling act once the leader has been reaped or its pid no longer provably names it. For code that must signal by pid (a descendant sweep) and would otherwise act on a number that may have been recycled. The lock is held for as long as act runs (that is what keeps a reap out), so every other thread’s wait, including a bounded one, is delayed by that long: keep act short, and never call back into this child from it. Windows has no recyclable-pid hazard here and always runs it.

Source

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

Source

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

Source

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

Source

pub fn job_assignment_failures(&self) -> &[JobAssignmentFailure]

Source

pub fn process_handle(&self) -> Result<ProcessHandle>

An independent exit reader. A monitor thread that only needs to learn that the leader exited should call ProcessHandle::wait_exited, which does not reap; wait reaps, and on Unix that ends the owner’s ability to signal descendants that outlive the leader.

Source

pub fn creation_time(&self) -> Option<SystemTime>

Source

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

Source

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

Source

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

Source

pub fn wait_or_kill(&mut self, grace: Duration) -> Result<WaitOutcome>

Asks the tree to stop, waits up to grace for the leader, then forces the tree down.

Unix: TERM goes to the group while the leader is still unreaped. If the leader exits within grace the result is Exited, but descendants that outlived it (or ignored TERM) are killed before the leader is reaped, while it still pins the group id. If it does not exit in time the whole group is killed and the result is Terminated.

Windows: if the leader exits within grace the result is Exited with its status, but the retained job is terminated first, so descendants that outlived it do not survive.

Source

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

Immediate forced termination, preserving the existing default. Windows: the retained job is signalled even after the parent was reaped. Unix: the group is signalled only while the leader is unreaped (see the type documentation); once any path has reaped it, only the reap result is returned.

Source

pub fn terminate_tree_with_options( &mut self, options: TerminationOptions, ) -> Result<ExitStatus>

Unix: TERM now, tree-wide grace, then KILL, all while the leader is unreaped (an exited leader stays unreaped until this call reaps it, so descendants still receive the KILL). If another path already reaped the leader, nothing is signalled. Windows: immediately terminate retained job with supplied exit code.

Source

pub fn terminate_tree_bounded( &mut self, timeout: Duration, ) -> Result<ReapOutcome>

Source

pub fn terminate_tree_bounded_with_options( &mut self, timeout: Duration, options: TerminationOptions, ) -> Result<ReapOutcome>

timeout covers grace plus reap; grace is clipped to timeout.

Source§

impl OwnedChild

Source

pub fn set_drop_reap_timeout(&mut self, timeout: Duration) -> &mut Self

How long dropping this child waits for the killed leader to be reaped (default DEFAULT_DROP_REAP_TIMEOUT). Drop sends the kill at once and never waits longer than this: a leader that has not been reaped by then (it is in an uninterruptible state, for instance) is reaped later by a background thread on Unix, and on Windows the process handle is closed. Duration::ZERO means “do not wait”. Does not affect terminate_tree, which still waits for the reap.

Source

pub fn drop_reap_timeout(&self) -> Duration

The bound Drop applies to the reap.

Source

pub fn descendant_identities(&self) -> Result<Vec<AdoptedIdentity>>

Identities of this child’s descendants (see crate::AdoptedIdentity::descendants), taken while the leader is proven to be this child. Empty once the leader has been reaped: its children are re-parented then and can no longer be found by their parent.

Trait Implementations§

Source§

impl Debug for OwnedChild

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for OwnedChild

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, !>

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.