Rid GCT os.Exit's in packages outside of main

This commit is contained in:
Adrian Gallagher
2019-09-27 15:18:54 +10:00
parent 3b1c0825f4
commit 6bdbe236c0
4 changed files with 45 additions and 36 deletions

28
signaler/signaler.go Normal file
View File

@@ -0,0 +1,28 @@
package signaler
import (
"os"
"os/signal"
"syscall"
)
var (
s = make(chan os.Signal, 1)
)
func init() {
sigs := []os.Signal{
os.Interrupt,
os.Kill,
syscall.SIGTERM,
syscall.SIGQUIT,
syscall.SIGABRT,
}
signal.Notify(s, sigs...)
}
// WaitForInterrupt waits until a os.Signal is
// received and returns the result
func WaitForInterrupt() os.Signal {
return <-s
}