mirror of
https://github.com/hashicorp/vault.git
synced 2026-06-04 06:15:02 -04:00
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:
parent
94d6b3ce94
commit
bc570e74f3
1 changed files with 5 additions and 4 deletions
|
|
@ -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{}{}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
Loading…
Reference in a new issue