github.com/rootless-containers/rootlesskit/v2@v2.3.4/pkg/sigproxy/signal/signal.go (about) 1 // Package signal provides helper functions for dealing with signals across 2 // various operating systems. 3 // 4 // Forked from https://github.com/moby/moby/tree/37defbfd9b968f38e8e15dfa5f06d9f878bd65ba/pkg/signal 5 package signal 6 7 import ( 8 "os" 9 "os/signal" 10 ) 11 12 // CatchAll catches all signals and relays them to the specified channel. 13 func CatchAll(sigc chan os.Signal) { 14 var handledSigs []os.Signal 15 for _, s := range SignalMap { 16 handledSigs = append(handledSigs, s) 17 } 18 signal.Notify(sigc, handledSigs...) 19 } 20 21 // StopCatch stops catching the signals and closes the specified channel. 22 func StopCatch(sigc chan os.Signal) { 23 signal.Stop(sigc) 24 close(sigc) 25 }