Documentation
¶
Overview ¶
Package signal provides the way to handle signal with github.com/oklog/run.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromError ¶
FromError returns os.Signal of run.SignalError.Signal if err is type of run.SignalError, otherwise nil.
func IgnoreError ¶
IgnoreError returns nil if err is type of run.SignalError.
Types ¶
type Signal ¶
Signal has a channel type of `chan os.Signal` and a handler function type of `func(os.Signal) error`.
func Notify ¶
Notify returns *Signal.
- Signal#C = make(chan os.Signal, 4)
- it calls signal.Notify(C, sig...)
- Signal#DefaultHandler is set to the signal handler of Signal returned.
func (*Signal) DefaultHandler ¶
DefaultHandler wraps si.Stop(), returns Error(sig).
func (*Signal) Receiver ¶
Receiver returns exec function and intr function, these can be used with run.Group#Add. exec waits a signal, then calls signal handler, returns its returned error if it is not nil. If the signal handler returns nil, exec does it again. exec returns immediately if intr is called.
EXAMPLE
sigint := signal.Notify(syscall.SIGINT) defer sigint.Stop() var g run.Group g.Add(sigint.Receiver())
func (*Signal) SetHandler ¶
SetHandler set f to si's signal handler if f is not nil, otherwise set si.DefaultHandler to it.