pub struct JobObject {
pid: Option<u32>,
}Expand description
Process group kill-guard for Unix. The child is spawned in a new session
(via setsid()), so it becomes the leader of a new process group. On drop,
the entire group is sent SIGKILL, ensuring no orphaned JVM subprocesses.
Fields§
§pid: Option<u32>Implementations§
Source§impl ProcessGroupGuard
impl ProcessGroupGuard
Sourcepub fn configure_command(&self, cmd: &mut Command)
pub fn configure_command(&self, cmd: &mut Command)
Configure the command to create a new process group / session.
Must be called before cmd.spawn().
Sourcepub fn assign(&mut self, child: &Child)
pub fn assign(&mut self, child: &Child)
Record the child PID so the guard can kill the process group on drop.
Sourcepub fn assign_pid(&mut self, pid: u32)
pub fn assign_pid(&mut self, pid: u32)
Record a bare PID (the leader of the process group) to kill on drop.
Sourcepub fn kill_group(&mut self) -> Result<()>
pub fn kill_group(&mut self) -> Result<()>
Kill the process group with SIGKILL. killpg takes a POSITIVE process-group id: the
leader’s PID is the group id (the child became group leader via setsid), and a
negated id is rejected with EINVAL. ESRCH means the group is already gone — the
normal case after a clean exit — so it maps to Ok(()). The pid is taken so the guard
is disarmed and a second call, and the Drop, are no-ops.