pub trait TreeReaper: Send + Sync {
const ADOPTION_IS_ATOMIC: bool;
// Required methods
fn adopt(&self, child: &Child) -> Result<()>;
fn kill_tree(&self) -> Result<()>;
}Expand description
Something that kills every descendant, not just the direct child.
Required Associated Constants§
Sourceconst ADOPTION_IS_ATOMIC: bool
const ADOPTION_IS_ATOMIC: bool
Whether a descendant can escape between spawn and adoption.
Unix process groups: no — process_group(0) takes effect before the
child’s first instruction. Windows without
PROC_THREAD_ATTRIBUTE_JOB_LIST: yes, because
std::process::Command cannot express CREATE_SUSPENDED, so a child
that forks immediately can outrun AssignProcessToJobObject. Reported
as data rather than buried in a comment, so a caller that needs
atomicity can assert on it and a later change can flip it.
Required Methods§
Sourcefn adopt(&self, child: &Child) -> Result<()>
fn adopt(&self, child: &Child) -> Result<()>
Take ownership of child and everything it goes on to spawn.
Sourcefn kill_tree(&self) -> Result<()>
fn kill_tree(&self) -> Result<()>
Kill the whole tree.
Windows is strictly stronger here and it is worth knowing why: a job
object with KILL_ON_JOB_CLOSE reaps the tree even if hotl itself
dies, which kill(-pgid) does not. And the pid-reuse hazard that makes
the Unix caller order its kill before the wait is moot on Windows — a
job handle is a kernel object, not a number that can be recycled.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".