You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
506 B
Go
26 lines
506 B
Go
|
4 weeks ago
|
//go:build linux
|
||
|
|
|
||
|
|
package worker
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os/exec"
|
||
|
|
"syscall"
|
||
|
|
)
|
||
|
|
|
||
|
|
func configureProcess(command *exec.Cmd) {
|
||
|
|
command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true, Pdeathsig: syscall.SIGKILL}
|
||
|
|
}
|
||
|
|
|
||
|
|
func terminateProcessGroup(command *exec.Cmd) {
|
||
|
|
if command.Process != nil {
|
||
|
|
_ = syscall.Kill(-command.Process.Pid, syscall.SIGTERM)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func killProcessGroup(command *exec.Cmd) {
|
||
|
|
if command.Process != nil {
|
||
|
|
_ = syscall.Kill(-command.Process.Pid, syscall.SIGKILL)
|
||
|
|
_ = command.Process.Kill()
|
||
|
|
}
|
||
|
|
}
|