Skip to main content

DaemonChild

Struct DaemonChild 

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

A daemon started by DaemonCommand::spawn.

Dropping it leaves the daemon running, as dropping a std::process::Child does. On Unix the daemon is also reaped once it exits, so a launcher that gives up on it leaves no zombie: at once if it has exited, otherwise by a thread that waits for it while it runs. That thread is best effort: if it cannot be created, a running daemon becomes a zombie when it exits, as before. Candidate::from takes it as a candidate that is stopped unless selected.

Its ProcessHandle is opened at spawn, before anything can reap the daemon, so it follows the daemon even in a process that ignores SIGCHLD.

Implementations§

Source§

impl DaemonChild

Source

pub fn id(&self) -> ProcessId

The daemon’s process ID.

Source

pub fn take_readiness(&mut self) -> Option<Channel>

The launcher’s end of the readiness channel, the first time it is asked for. None without DaemonCommand::readiness_channel.

Source

pub fn in_callers_job(&self) -> bool

True when the daemon was left in the caller’s job object because that job forbids breakaway, so it will die with the caller’s job (see the job objects section of DaemonCommand). Always false on Unix, which has no job objects.

False does not prove the daemon is in no job. With nested jobs, a job that allows breakaway lets the daemon leave it even when an enclosing job does not; the daemon then stays in that outer job without the breakaway being refused.

Source

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

The exit status if the daemon has exited, without blocking.

Source

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

Block until the daemon exits.

Source

pub fn wait_until(&mut self, deadline: Instant) -> Result<Option<ExitStatus>>

Block until the daemon exits or deadline passes: its exit status, or None while it still runs.

The status comes from waiting for the child, so in a process that ignores SIGCHLD, where the kernel discards it, this fails after the exit. Self::exit_handle still reports the exit there.

Source

pub fn exit_handle(&mut self) -> &mut ProcessHandle

The daemon’s exit as an event, for a caller that waits on it together with other work, for example with exited under the async feature.

Source

pub fn wait_until_live( &mut self, deadline: Instant, is_live: impl FnMut() -> bool, ) -> Result<Startup>

Probe with is_live until it succeeds, the daemon exits, or deadline passes.

Between probes this waits on the daemon’s exit rather than sleeping, for POLL at most, so a daemon that dies during startup ends the wait at once. is_live must attempt a connect or a protocol probe and bound its own blocking. An error means the exit could not be observed; the daemon may still be running.

Source

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

Stop the daemon forcibly: SIGKILL on Unix, TerminateProcess on Windows. A daemon that already exited is not an error.

Trait Implementations§

Source§

impl Debug for DaemonChild

Source§

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

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

impl From<DaemonChild> for Candidate

Available on crate feature launch only.

A daemon started by DaemonCommand as a candidate: dropped before Candidate::selected, it is stopped. Take its readiness channel first; the candidate keeps it but does not give it out.

Source§

fn from(daemon: DaemonChild) -> Self

Converts to this type from the input type.

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.