Commit a8d7e93d authored by Bryan Boreham's avatar Bryan Boreham Committed by Bryan Boreham

Change process group when sending kill signal

Otherwise when the target process is running sudo it ignores the signal.
parent 0b1f0e83
...@@ -361,7 +361,10 @@ func (k *killCmd) Kill() error { ...@@ -361,7 +361,10 @@ func (k *killCmd) Kill() error {
const timeout = 10 * time.Second const timeout = 10 * time.Second
for _, signal := range []string{"-TERM", "-KILL"} { for _, signal := range []string{"-TERM", "-KILL"} {
glog.V(2).Infof("Killing process %d (%s) with %s", pid, name, signal) glog.V(2).Infof("Killing process %d (%s) with %s", pid, name, signal)
_, err := exec.Command("sudo", "kill", signal, strconv.Itoa(pid)).Output() cmd := exec.Command("sudo", "kill", signal, strconv.Itoa(pid))
// Run the 'kill' command in a separate process group so sudo doesn't ignore it
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
_, err := cmd.Output()
if err != nil { if err != nil {
glog.Errorf("Error signaling process %d (%s) with %s: %v", pid, name, signal, err) glog.Errorf("Error signaling process %d (%s) with %s: %v", pid, name, signal, err)
continue continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment