2014-03-10 16:38:17 -04:00
|
|
|
package signal
|
2013-10-29 14:59:08 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
)
|
|
|
|
|
2014-03-10 16:50:16 -04:00
|
|
|
func CatchAll(sigc chan os.Signal) {
|
|
|
|
handledSigs := []os.Signal{}
|
2014-03-10 17:22:27 -04:00
|
|
|
for _, s := range SignalMap {
|
2014-03-10 16:50:16 -04:00
|
|
|
handledSigs = append(handledSigs, s)
|
|
|
|
}
|
|
|
|
signal.Notify(sigc, handledSigs...)
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:59:08 -04:00
|
|
|
func StopCatch(sigc chan os.Signal) {
|
|
|
|
signal.Stop(sigc)
|
|
|
|
close(sigc)
|
|
|
|
}
|