pub enum RunningState {
Running,
Terminated(ExitStatus),
Uncertain(Error),
}Expand description
Represents the running state of a process.
Variants§
Running
The process is still running.
Terminated(ExitStatus)
The process has terminated with the given exit status.
Uncertain(Error)
Reaping the child failed, so the actual state could not be observed.
The conservative reading is “still running”: until termination has been confirmed, the
drop-cleanup and panic guards on the handle are still required, and the process may yet
produce output. The variant carries the underlying io::Error so callers can log or
retry at their discretion; treating it as “not running” risks dropping a still-live child.
RunningState::is_definitely_running returns false here on purpose so callers cannot
mistake “we don’t know” for “still running” via a single boolean check, but matching on
the enum is the only way to distinguish RunningState::Terminated from this case.
Implementations§
Source§impl RunningState
impl RunningState
Sourcepub fn is_definitely_running(&self) -> bool
pub fn is_definitely_running(&self) -> bool
Returns true only when the state is RunningState::Running.
Both RunningState::Terminated and RunningState::Uncertain return false. The
asymmetry is intentional: callers who need to distinguish “not running” from “we don’t
know” should match the enum directly. The error carried by
RunningState::Uncertain is real and worth surfacing, not silently collapsing.
Even when this returns false for an RunningState::Uncertain state, the safe
interpretation is still “the process may be running”; do not use this predicate to decide
whether it is safe to drop the handle. See RunningState::Uncertain.