Closed
Description
Is your feature request related to a problem? Please describe.
I want to create a child process and later be able to kill this child with all of it's sub- and sub-sub- children on unix-style operating systems.
Describe the solution you'd like
Something along the lines of:
.set_process_group(0)
Describe alternatives you've considered
I'm currently using this code to implement it:
unsafe {
cmd.pre_exec(|| {
// create a new process group
let pid = nix::unistd::getpid();
if let Err(err) = nix::unistd::setpgid(pid, Pid::from_raw(0)) {
warn!("Failed to create new process group: {:#?}", err);
}
Ok(())
});
}
setpgid
needs to be called before exec
is called after fork
.
Additional context
https://www.gnu.org/software/libc/manual/html_node/Process-Group-Functions.html