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