pub struct AdoptedIdentity { /* private fields */ }Expand description
A pid together with the start time and executable path that make it a name for exactly one process. See the module documentation.
Implementations§
Source§impl AdoptedIdentity
impl AdoptedIdentity
Sourcepub fn capture(pid: NonZeroU32) -> Result<Option<Self>>
pub fn capture(pid: NonZeroU32) -> Result<Option<Self>>
Reads the identity of pid. Ok(None) when no process has that pid. The caller is
responsible for pid naming the intended process at this moment (it was just spawned
by a launcher, or it was just read from the owner’s own record).
Sourcepub fn from_recorded(
pid: NonZeroU32,
start: StartToken,
exe: Option<PathBuf>,
) -> Self
pub fn from_recorded( pid: NonZeroU32, start: StartToken, exe: Option<PathBuf>, ) -> Self
Rebuilds an identity persisted earlier (a pid file that also records
start_token and exe).
pub fn pid(&self) -> u32
pub fn start_token(&self) -> StartToken
pub fn exe(&self) -> Option<&Path>
Sourcepub fn from_recorded_unix_ms(
pid: NonZeroU32,
recorded_unix_ms: u64,
tolerance: Duration,
) -> Result<Option<Self>>
pub fn from_recorded_unix_ms( pid: NonZeroU32, recorded_unix_ms: u64, tolerance: Duration, ) -> Result<Option<Self>>
Verifies a pid recorded by an earlier run of this program as Unix epoch milliseconds.
Returns the identity (with the host’s exact start token) when the pid names a process
that started within tolerance of recorded_unix_ms, and None when the pid names no
process, names one that started at a different time (a recycled pid), or the host cannot
report start times. Epoch milliseconds are a coarse name, so the tolerance matters: a
start that is off by more than it is refused.
Sourcepub fn start_time(&self) -> Option<SystemTime>
pub fn start_time(&self) -> Option<SystemTime>
When the process started, as a wall-clock time: exact on macOS (microseconds) and
Windows (100 ns); on Linux, the boot time plus the start ticks (one clock tick of
resolution). None where the host reports no start time or the value is out of range.
Sourcepub fn verify(&self) -> Result<IdentityCheck>
pub fn verify(&self) -> Result<IdentityCheck>
Whether the pid still names the remembered process.
Sourcepub fn is_running(&self) -> Result<bool>
pub fn is_running(&self) -> Result<bool>
Whether the remembered process is still running. A zombie (exited, awaiting its own
parent’s reap) is dead here although verify still names it Same;
this crate never reaps it. Windows has no zombies: an exited process already reads
Gone.
Sourcepub fn confirmed_gone(&self) -> Result<bool>
pub fn confirmed_gone(&self) -> Result<bool>
Confirmed gone: the remembered process itself is not running any more (the pid names
nothing, names a different process, or is a dead zombie). Descendants and a process
group are separate observations: take descendants while the
root lives and check each, or wait on the group with wait_process_group_empty.
Sourcepub fn wait_confirmed_gone(&self, timeout: Duration) -> Result<bool>
pub fn wait_confirmed_gone(&self, timeout: Duration) -> Result<bool>
Waits at most timeout for confirmed_gone; Ok(false) when
the remembered process is still running then. Sends no signal.
Sourcepub fn quit_gracefully(&self, timeout: Duration) -> Result<bool>
pub fn quit_gracefully(&self, timeout: Duration) -> Result<bool>
Identity-pinned graceful quit: one Graceful signal to exactly this process, then at
most timeout of waiting for it to be confirmed gone. Never escalates; a target that
stays up yields Ok(false). A pid that changed hands is never signalled.
Sourcepub fn signal(&self, signal: AdoptedSignal) -> Result<SignalResult>
pub fn signal(&self, signal: AdoptedSignal) -> Result<SignalResult>
Sends signal only if the pid still names the remembered process. Never signals this
process: that is InvalidInput.
Sourcepub fn suspend(&self) -> Result<SignalResult>
pub fn suspend(&self) -> Result<SignalResult>
Suspends the process (SIGSTOP) only if the pid still names the remembered process.
Unix only; Windows returns Unsupported. Never signals this process (InvalidInput).
Sourcepub fn resume(&self) -> Result<SignalResult>
pub fn resume(&self) -> Result<SignalResult>
Resumes a process stopped by suspend (SIGCONT) only if the pid
still names the remembered process. Unix only; Windows returns Unsupported.
Sourcepub fn descendants(&self) -> Result<Vec<AdoptedIdentity>>
pub fn descendants(&self) -> Result<Vec<AdoptedIdentity>>
The descendants of this process, parents before children, each with its own identity. Empty when this process is gone or the pid now names a different one. A child is accepted only if it did not start before its parent, so a stale parent link to a recycled pid adds nothing.