//go:build unix package ingest import ( "os" "os/exec" "syscall" ) // setProcessGroup puts the engine in a process group of its own so that stopping a run reaches // everything it started, not only the process whose pid we happen to hold (PD-13). // // It does NOT survive a crash of the platform: a killed supervisor leaves the group running, and // only the deploy unit's cgroup closes that hole — see deploy/tmplatformd.service. func setProcessGroup(cmd *exec.Cmd) { cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} } // interruptGroup asks the whole group to stop. A negative pid is the POSIX spelling of "group"; // if the group is already gone, the single process is still worth the signal. func interruptGroup(p *os.Process) error { if err := syscall.Kill(-p.Pid, syscall.SIGINT); err != nil { return p.Signal(os.Interrupt) } return nil } // stillRunning reports whether the process can still be signalled by us. func stillRunning(p *os.Process) bool { return p.Signal(syscall.Signal(0)) == nil }