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
impl DaemonChild
Sourcepub fn take_readiness(&mut self) -> Option<Channel>
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.
Sourcepub fn in_callers_job(&self) -> bool
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.
Sourcepub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
pub fn try_wait(&mut self) -> Result<Option<ExitStatus>>
The exit status if the daemon has exited, without blocking.
Sourcepub fn wait(&mut self) -> Result<ExitStatus>
pub fn wait(&mut self) -> Result<ExitStatus>
Block until the daemon exits.
Sourcepub fn wait_until(&mut self, deadline: Instant) -> Result<Option<ExitStatus>>
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.
Sourcepub fn exit_handle(&mut self) -> &mut ProcessHandle
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.
Sourcepub fn wait_until_live(
&mut self,
deadline: Instant,
is_live: impl FnMut() -> bool,
) -> Result<Startup>
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.
Trait Implementations§
Source§impl Debug for DaemonChild
impl Debug for DaemonChild
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.
impl From<DaemonChild> for Candidate
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.