Documentation ¶
Overview ¶
Package signal provides methods for handling POSIX signals
Index ¶
Examples ¶
Constants ¶
View Source
const ( ABRT = syscall.SIGABRT // ABRT signal code ALRM = syscall.SIGALRM // ALRM signal code BUS = syscall.SIGBUS // BUS signal code CHLD = syscall.SIGCHLD // CHLD signal code CONT = syscall.SIGCONT // CONT signal code FPE = syscall.SIGFPE // FPE signal code HUP = syscall.SIGHUP // HUP signal code ILL = syscall.SIGILL // ILL signal code INT = syscall.SIGINT // INT signal code IO = syscall.SIGIO // IO signal code IOT = syscall.SIGIOT // IOT signal code KILL = syscall.SIGKILL // KILL signal code PIPE = syscall.SIGPIPE // PIPE signal code PROF = syscall.SIGPROF // PROF signal code QUIT = syscall.SIGQUIT // QUIT signal code SEGV = syscall.SIGSEGV // SEGV signal code STOP = syscall.SIGSTOP // STOP signal code SYS = syscall.SIGSYS // SYS signal code TERM = syscall.SIGTERM // TERM signal code TRAP = syscall.SIGTRAP // TRAP signal code TSTP = syscall.SIGTSTP // TSTP signal code TTIN = syscall.SIGTTIN // TTIN signal code TTOU = syscall.SIGTTOU // TTOU signal code URG = syscall.SIGURG // URG signal code USR1 = syscall.SIGUSR1 // USR1 signal code USR2 = syscall.SIGUSR2 // USR2 signal code VTALRM = syscall.SIGVTALRM // VTALRM signal code WINCH = syscall.SIGWINCH // WINCH signal code XCPU = syscall.SIGXCPU // XCPU signal code XFSZ = syscall.SIGXFSZ // XFSZ signal code )
Signal codes
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handlers ¶
Handlers is map signal → handler
func (Handlers) Track ¶
func (h Handlers) Track()
Track catches signal and executes handler for this signal
Example ¶
hupHandler := func() { fmt.Println("Got HUP signal") } usr1Handler := func() { fmt.Println("Got USR1 signal") } Handlers{ HUP: hupHandler, USR1: usr1Handler, }.Track()
Output:
func (Handlers) TrackAsync ¶
func (h Handlers) TrackAsync()
TrackAsync catches signal and executes async handler for this signal
Example ¶
hupHandler := func() { fmt.Println("Got HUP signal") } usr1Handler := func() { fmt.Println("Got USR1 signal") } Handlers{ HUP: hupHandler, USR1: usr1Handler, }.TrackAsync() time.Sleep(time.Hour)
Output:
Click to show internal directories.
Click to hide internal directories.