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