e6956aa001
- React frontend with route-level code splitting - Backend rebranded from Baihu to TaskPool - DB brand migration script and local compatibility
22 lines
412 B
Go
22 lines
412 B
Go
//go:build !windows
|
|
|
|
package executor
|
|
|
|
import (
|
|
"os/exec"
|
|
"syscall"
|
|
)
|
|
|
|
func SetProcessGroupAndCancel(cmd *exec.Cmd, usePty bool) {
|
|
if !usePty {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
}
|
|
cmd.Cancel = func() error {
|
|
if cmd.Process != nil {
|
|
// Kill the entire process group by sending SIGKILL to negative PID
|
|
return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
|
|
}
|
|
return nil
|
|
}
|
|
}
|