Skip to main content

AdoptedIdentity

Struct AdoptedIdentity 

Source
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

Source

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).

Source

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).

Source

pub fn pid(&self) -> u32

Source

pub fn start_token(&self) -> StartToken

Source

pub fn exe(&self) -> Option<&Path>

Source

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.

Source

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.

Source

pub fn verify(&self) -> Result<IdentityCheck>

Whether the pid still names the remembered process.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for AdoptedIdentity

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AdoptedIdentity

Source§

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

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

impl Eq for AdoptedIdentity

Source§

impl PartialEq for AdoptedIdentity

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AdoptedIdentity

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.