mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #51143 from oomichi/issue/43051
Automatic merge from submit-queue (batch tested with PRs 51038, 50063, 51257, 47171, 51143) Add signal handler for catching Ctrl-C on hack/e2e **What this PR does / why we need it**: When operating e2e test, hack/e2e.go process creates kubetest process. To kill the kubetest process when stop e2e test with Ctrl-C, we need to send the signal to the process because it also creates another process and it needs to kill it. This PR adds the signal handler on hack/e2e.go to kill the kubetest process. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # fixes #43051 **Special notes for your reviewer**: https://github.com/kubernetes/test-infra/pull/4154 is the part of kubetest. **Release note**: `NONE`
This commit is contained in:
commit
acdf625e46
10
hack/e2e.go
10
hack/e2e.go
@ -25,6 +25,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@ -81,12 +82,21 @@ func main() {
|
||||
}
|
||||
|
||||
func wait(cmd string, args ...string) error {
|
||||
sigChannel := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChannel, os.Interrupt)
|
||||
|
||||
c := exec.Command(cmd, args...)
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if err := c.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
sig := <-sigChannel
|
||||
if err := c.Process.Signal(sig); err != nil {
|
||||
log.Fatalf("could not send %s signal %s: %v", cmd, sig, err)
|
||||
}
|
||||
}()
|
||||
return c.Wait()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user