mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +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:
		
							
								
								
									
										10
									
								
								hack/e2e.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								hack/e2e.go
									
									
									
									
									
								
							@@ -25,6 +25,7 @@ import (
 | 
				
			|||||||
	"log"
 | 
						"log"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"os/exec"
 | 
						"os/exec"
 | 
				
			||||||
 | 
						"os/signal"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
@@ -81,12 +82,21 @@ func main() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func wait(cmd string, args ...string) error {
 | 
					func wait(cmd string, args ...string) error {
 | 
				
			||||||
 | 
						sigChannel := make(chan os.Signal, 1)
 | 
				
			||||||
 | 
						signal.Notify(sigChannel, os.Interrupt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c := exec.Command(cmd, args...)
 | 
						c := exec.Command(cmd, args...)
 | 
				
			||||||
	c.Stdout = os.Stdout
 | 
						c.Stdout = os.Stdout
 | 
				
			||||||
	c.Stderr = os.Stderr
 | 
						c.Stderr = os.Stderr
 | 
				
			||||||
	if err := c.Start(); err != nil {
 | 
						if err := c.Start(); err != nil {
 | 
				
			||||||
		return err
 | 
							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()
 | 
						return c.Wait()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user