mirror of
https://github.com/boolean-maybe/tiki
synced 2026-04-21 13:37:20 +00:00
18 lines
451 B
Go
18 lines
451 B
Go
//go:build !windows
|
|
|
|
package service
|
|
|
|
import (
|
|
"os/exec"
|
|
"syscall"
|
|
)
|
|
|
|
// setProcessGroup configures the command to run in its own process group
|
|
// and overrides Cancel to kill the entire group (parent + children).
|
|
func setProcessGroup(cmd *exec.Cmd) {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
cmd.Cancel = func() error {
|
|
// negative pid → kill the whole process group
|
|
return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
|
|
}
|
|
}
|