Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // MAXSIG is the largest number of non-realtime signals (on Linux). // 32..64 are realtime signals and irrelevant to us at this point. MAXSIG = 31 )
Variables ¶
This section is empty.
Functions ¶
func Alarm ¶
func Alarm(seconds int)
Alarm sets up a timer so a SIGALRM signal is fired after 'seconds' seconds.
Example ¶
sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.Signal(syscall.SIGALRM)) Alarm(1) t0 := time.Now().Unix() fmt.Println("... do work here ...") sig := <-sigs // wait for SIGALRM fmt.Printf("Got '%s' after %ds\n", sig.String(), time.Now().Unix()-t0)
Output: ... do work here ... Got 'alarm clock' after 1s
Types ¶
type Handler ¶
Handler is used to handle the handle INT, TERM and CHLD signals.
func New ¶
func New() Handler
New initializes the signal handlers. We now get events for all signals. Read the Handler.Chan and handle them appropriately.
func NewAlarmHupUsr1 ¶
func NewAlarmHupUsr1() Handler
NewAlarmHupUsr1 initializes signal handlers for ALRM, HUP and USR1. Read the Handler.Chan and handle them appropriately.
Click to show internal directories.
Click to hide internal directories.