Skip to content

Commit 94ae32b

Browse files
committed
Fix Signal deadlock that prevented shutdown
1 parent 971c6d6 commit 94ae32b

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

cmd/kubexit/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ func main() {
134134
// ShutdownWithTimeout doesn't block until timeout
135135
if err != nil {
136136
log.Printf("Error: failed to shutdown: %v\n", err)
137-
return
138137
}
139138
}))
140139
if err != nil {

pkg/supervisor/supervisor.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,6 @@ func (s *Supervisor) Wait() error {
8484
return s.cmd.Wait()
8585
}
8686

87-
func (s *Supervisor) Signal(sig os.Signal) error {
88-
s.startStopLock.Lock()
89-
defer s.startStopLock.Unlock()
90-
91-
// Process set by Start
92-
if s.cmd.Process == nil {
93-
return errors.New("cannot signal unstarted child process")
94-
}
95-
96-
err := s.cmd.Process.Signal(sig)
97-
if err != nil {
98-
return fmt.Errorf("failed to signal child process: %v", err)
99-
}
100-
return nil
101-
}
102-
10387
func (s *Supervisor) ShutdownNow() error {
10488
s.startStopLock.Lock()
10589
defer s.startStopLock.Unlock()
@@ -112,7 +96,7 @@ func (s *Supervisor) ShutdownNow() error {
11296
log.Println("Killing child process...")
11397
// TODO: Use Process.Kill() instead?
11498
// Sending Interrupt on Windows is not implemented.
115-
err := s.Signal(syscall.SIGKILL)
99+
err := s.cmd.Process.Signal(syscall.SIGKILL)
116100
if err != nil {
117101
return fmt.Errorf("failed to kill child process: %v", err)
118102
}
@@ -133,7 +117,7 @@ func (s *Supervisor) ShutdownWithTimeout(timeout time.Duration) error {
133117
}
134118

135119
log.Println("Terminating child process...")
136-
err := s.Signal(syscall.SIGTERM)
120+
err := s.cmd.Process.Signal(syscall.SIGTERM)
137121
if err != nil {
138122
return fmt.Errorf("failed to terminate child process: %v", err)
139123
}

0 commit comments

Comments
 (0)