From a8d7e93d666d2b0dcdc8e1af2ddbb72de60be7a1 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 21 Jul 2016 15:11:03 +0100 Subject: [PATCH 1/2] Change process group when sending kill signal Otherwise when the target process is running sudo it ignores the signal. --- test/e2e_node/e2e_service.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/e2e_node/e2e_service.go b/test/e2e_node/e2e_service.go index 76f185756ca..e697b2f8e20 100644 --- a/test/e2e_node/e2e_service.go +++ b/test/e2e_node/e2e_service.go @@ -361,7 +361,10 @@ func (k *killCmd) Kill() error { const timeout = 10 * time.Second for _, signal := range []string{"-TERM", "-KILL"} { 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 { glog.Errorf("Error signaling process %d (%s) with %s: %v", pid, name, signal, err) continue From e5e7b60e9ac00a60f7767a71054500294c12b484 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 21 Jul 2016 15:19:39 +0100 Subject: [PATCH 2/2] Remove Pdeathsig code because it doesn't do what was intended Pdeathsig is applied to the process we are starting, so that will get killed if the e2e_node process dies, which isn't what we need. --- test/e2e_node/e2e_service.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/e2e_node/e2e_service.go b/test/e2e_node/e2e_service.go index e697b2f8e20..6fc7ac9b5e8 100644 --- a/test/e2e_node/e2e_service.go +++ b/test/e2e_node/e2e_service.go @@ -26,7 +26,6 @@ import ( "os/exec" "path" "path/filepath" - "reflect" "strconv" "strings" "syscall" @@ -284,18 +283,6 @@ func (es *e2eService) startServer(cmd *healthCheckCommand) error { cmd.Cmd.Stdout = outfile cmd.Cmd.Stderr = outfile - // Killing the sudo command should kill the server as well. - attrs := &syscall.SysProcAttr{} - // Hack to set linux-only field without build tags. - deathSigField := reflect.ValueOf(attrs).Elem().FieldByName("Pdeathsig") - if deathSigField.IsValid() { - deathSigField.Set(reflect.ValueOf(syscall.SIGKILL)) - } else { - cmdErrorChan <- fmt.Errorf("Failed to set Pdeathsig field (non-linux build)") - return - } - cmd.Cmd.SysProcAttr = attrs - // Run the command err = cmd.Run() if err != nil {