pub struct ParentFence { /* private fields */ }Expand description
A parent-process identity fence: the parent’s pid pinned to its OS start marker, so a
different process that later reuses the pid is never mistaken for the parent. A child
whose parent cannot hold its stdin open (or must not rely on it alone) captures this at
start and stops itself when parent_gone turns true; conversely a
reused pid alone can neither keep the child alive nor claim to be its parent.
Implementations§
Source§impl ParentFence
impl ParentFence
Sourcepub fn capture(pid: u32) -> Self
pub fn capture(pid: u32) -> Self
Capture process pid’s identity now (its start marker as the OS reports it;
None when unreadable, in which case the fence falls back to pid liveness and a
reused pid cannot be told apart — see parent_gone).
Sourcepub fn from_parts(pid: u32, started: Option<(u64, u64)>) -> Self
pub fn from_parts(pid: u32, started: Option<(u64, u64)>) -> Self
A fence from a pid and a start marker captured elsewhere (for example handed to the child at spawn, before any reuse could happen).
pub fn pid(&self) -> u32
Sourcepub fn started(&self) -> Option<(u64, u64)>
pub fn started(&self) -> Option<(u64, u64)>
The captured start marker, when the OS reported one.
Sourcepub fn parent_gone(&self) -> bool
pub fn parent_gone(&self) -> bool
True when the fenced parent is gone: with a captured start marker, when the pid’s current marker differs (the process exited, or the pid was reused by another process); without one, when the pid is no longer alive.