> But I'm not sure about trap all different signals
signal.Notify(interrupted), which is what the docs say:
"Notify causes package signal to relay incoming signals to c. If no
signals are listed, all incoming signals will be relayed to c.
Otherwise, just the listed signals will."
You should really buffer that channel.
func Notify(c chan<- os.Signal, sig ...os.Signal)
Notify causes package signal to relay incoming signals to c. If no
signals are listed, all incoming signals will be relayed to c.
Otherwise, just the listed signals will.
Package signal will not block sending to c: the caller must ensure that
c has sufficient buffer space to keep up with the expected signal rate.
For a channel used for notification of just one signal value, a buffer
of size 1 is sufficient.
Another tiny problem: you can't catch SIGKILL.
Be careful not to catch SIGFLU.
Tonic
If you replace 'change' by a new channel, it won't receive the signal
notifications.
Rémy.