pub struct DetachedChild { /* private fields */ }Expand description
A minimal handle to a child spawned outside this crate’s kill-on-drop
containment via Command::spawn_detached.
§Warning — this inverts the crate’s headline guarantee
Everywhere else, processkit guarantees a child — and everything it spawns —
dies with its owner (kill-on-drop). A DetachedChild is the crate’s one
deliberate exception: the child was launched into its own session (Unix
setsid) and is not assigned to this crate’s containment (no Windows Job
Object / cgroup / process-group tracking), so dropping this handle does
nothing to the child — it keeps running, and its lifetime is now entirely
yours to manage.
That is why this is a separate, non-interchangeable type, not a
RunningProcess: it deliberately exposes no
public kill, wait, timeout, output capture, or teardown/control verbs. All
it carries is the child’s pid. On Unix, a private background
reaper owns the OS child handle and collects its exit status; this public
handle still exposes none of those operations. If you need any of those, you
need containment — use Command::start instead and
keep the handle.
Not contained by this crate — but a host container may still bind it.
spawn_detached deliberately does not
break out of an external Job Object / cgroup that already contains your
process (a CI runner, a systemd scope, this crate’s own supervisor); doing
so would be hostile to whoever set that containment up. So a detached child
escapes only this crate’s per-run containment, not a broader host one it
inherits.
Implementations§
Source§impl DetachedChild
impl DetachedChild
Sourcepub fn pid(&self) -> u32
pub fn pid(&self) -> u32
The OS process id of the detached child, as reported at spawn.
The pid can be recycled by the OS once the child exits and the Unix background reaper (or the platform’s normal process cleanup) has collected it. Treat it as a spawn-time identifier, not a durable handle to a still-live process.