Fix SIGINT handling.

No signal handler was setup to receive SIGINT.  I didn't investigate to
see if signal(2) mask was setup (ala `SIG_IGN`) or if sigprocmask(2) is
being used, but in either case, the correct behavior is to capture and
treat SIGINT the same as SIGTERM.  At some point in the future these two
signals may affect the running process differently, but we will clarify
that difference in the future.
This commit is contained in:
Sean Chittenden
2016-04-15 10:03:22 -07:00
parent 94d6b3ce94
commit bc570e74f3

View File

@@ -666,15 +666,16 @@ General Options:
// MakeShutdownCh returns a channel that can be used for shutdown
// notifications for commands. This channel will send a message for every
// interrupt or SIGTERM received.
// SIGINT or SIGTERM received.
func MakeShutdownCh() chan struct{} {
resultCh := make(chan struct{})
signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM)
shutdownCh := make(chan os.Signal, 4)
signal.Notify(shutdownCh, os.Interrupt, syscall.SIGINT)
signal.Notify(shutdownCh, os.Interrupt, syscall.SIGTERM)
go func() {
for {
<-signalCh
<-shutdownCh
resultCh <- struct{}{}
}
}()