mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Rid GCT os.Exit's in packages outside of main
This commit is contained in:
28
signaler/signaler.go
Normal file
28
signaler/signaler.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user