//go:build unix package tools import ( "os/exec" "syscall" ) // setPgroup puts the bash child in its own process group so a timeout or // cancel kills the whole tree, not just the shell (crush/maki gotcha: // plain Kill orphans grandchildren). func setPgroup(c *exec.Cmd) { c.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} } // killGroup SIGKILLs the child's process group after Wait; no-op if the // child never started. func killGroup(c *exec.Cmd) { if c.Process == nil { return } _ = syscall.Kill(-c.Process.Pid, syscall.SIGKILL) }