github.com/rsampaio/docker@v0.7.2-0.20150827203920-fdc73cc3fc31/pkg/signal/signal.go (about) 1 // Package signal provides helper functions for dealing with signals across 2 // various operating systems. 3 package signal 4 5 import ( 6 "os" 7 "os/signal" 8 ) 9 10 // CatchAll catches all signals and relays them to the specified channel. 11 func CatchAll(sigc chan os.Signal) { 12 handledSigs := []os.Signal{} 13 for _, s := range SignalMap { 14 handledSigs = append(handledSigs, s) 15 } 16 signal.Notify(sigc, handledSigs...) 17 } 18 19 // StopCatch stops catching the signals and closes the specified channel. 20 func StopCatch(sigc chan os.Signal) { 21 signal.Stop(sigc) 22 close(sigc) 23 }