moby--moby/pkg/signal/signal.go

24 lines
553 B
Go
Raw Normal View History

// Package signal provides helper functions for dealing with signals across
// various operating systems.
package signal
2013-10-29 18:59:08 +00:00
import (
"os"
"os/signal"
)
// CatchAll catches all signals and relays them to the specified channel.
func CatchAll(sigc chan os.Signal) {
handledSigs := []os.Signal{}
for _, s := range SignalMap {
handledSigs = append(handledSigs, s)
}
signal.Notify(sigc, handledSigs...)
}
// StopCatch stops catching the signals and closes the specified channel.
2013-10-29 18:59:08 +00:00
func StopCatch(sigc chan os.Signal) {
signal.Stop(sigc)
close(sigc)
}