diff --git a/test/e2e_node/e2e_service.go b/test/e2e_node/e2e_service.go index db56e15cf9a..0ebb0270718 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" @@ -295,18 +294,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 { @@ -372,7 +359,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