pub struct OwnedChild { /* private fields */ }Implementations§
Source§impl OwnedChild
impl OwnedChild
pub fn id(&self) -> u32
Sourcepub fn child(&self) -> MutexGuard<'_, UnixChild>
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.)
Sourcepub fn while_unreaped<R>(&self, act: impl FnOnce(u32) -> R) -> Result<Option<R>>
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.
pub fn take_stdin(&mut self) -> Option<ChildStdin>
pub fn take_stdout(&mut self) -> Option<ChildStdout>
pub fn take_stderr(&mut self) -> Option<ChildStderr>
pub fn job_assignment_failures(&self) -> &[JobAssignmentFailure]
Sourcepub fn process_handle(&self) -> Result<ProcessHandle>
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.
pub fn creation_time(&self) -> Option<SystemTime>
pub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
pub fn wait(&mut self) -> Result<ExitStatus>
pub fn wait_timeout(&mut self, timeout: Duration) -> Result<Option<ExitStatus>>
Sourcepub fn wait_or_kill(&mut self, grace: Duration) -> Result<WaitOutcome>
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.
Sourcepub fn terminate_tree(&mut self) -> Result<ExitStatus>
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.
Sourcepub fn terminate_tree_with_options(
&mut self,
options: TerminationOptions,
) -> Result<ExitStatus>
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.
pub fn terminate_tree_bounded( &mut self, timeout: Duration, ) -> Result<ReapOutcome>
Sourcepub fn terminate_tree_bounded_with_options(
&mut self,
timeout: Duration,
options: TerminationOptions,
) -> Result<ReapOutcome>
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
impl OwnedChild
Sourcepub fn set_drop_reap_timeout(&mut self, timeout: Duration) -> &mut Self
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.
Sourcepub fn drop_reap_timeout(&self) -> Duration
pub fn drop_reap_timeout(&self) -> Duration
The bound Drop applies to the reap.
Sourcepub fn descendant_identities(&self) -> Result<Vec<AdoptedIdentity>>
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.