.TH SIGNAL 2 .UC 4 .SH NAME signal, sigaction, sigsuspend, sigpending, sgetmask, ssetmask \- signal handling functions. .SH SYNOPSIS .nf .B #include .B #include .B int sigaction(int signum, const struct sigaction *new, .ti 21 .B struct sigaction *old); .B void (*signal(int signum, (void *handler)(int))))(int) .B sigsuspend(int restart, sigset_t old_mask, sigset_t set); .B int sigpending(sigset_t *buf); .B sigset_t sgetmask (void); .B sigset_t ssetmask (sigset_t mask); .fi .SH DESCRIPTION .B sgetmask() and .B ssetmask() get and set the mask of blocked signals. Signals are bitmapped into this mask as 1 << (signum - 1). Both return the old value of the mask. Note that .B SIGKILL and .B SIGSTOP cannot be blocked. .PP .B sigpending() fills in .I *buf with which signals are pending but blocked. 0 is returned. .PP .B sigsuspend() is used to atomically swap out the signal mask, while waiting for a signal. If the .I restart flag is set, then the current mask is replaced with old_mask, and sigsuspend exists with a .B -EINTR. Otherwise, the current signal mask is set to set, a .B pause() system call performed, and .B -ERESTARTNOINTR is returned. .PP .B signal() is used to set up a signal handler for .I signum. The signal handler is set to .I handler, which may be a user specified function or one of these from signal.h: .br .B SIG_DFL - use the default handler. .br .B SIG_IGN - ignore signal. .PP Note that .B signal() sets up signals to be SA_ONESHOT and SA_NOMASK. This may be changed by a call to .B sigaction(). .PP Also note that SIG_KILL and SIG_STOP cannot be changed. .PP The address of the handler is returned on success, a negative value on error. .PP .B sigaction() is similar to a more general version of .B signal(). It can be used to set the entire .B sigaction structure for a signal. .PP If .I old is non null, the old action will be stored there. The action will then be set to .I new. .bp .PP The .BB sigaction structure is as defined in /usr/include/signal.h : .br .nf struct sigaction { .in 24 void (*sa_handler)(int); sigset_t sa_mask; int sa_flags; void (*sa_restorer)(void); }; .in 10 .fi .PP 0 is returned on success. Note that .B SIGKILL and .B SIGSTOP may not have signals set for them. .SH ERRORS .B -EINVAL is returned when an invalid signum is passed to the functions. .SH FILES linux/signal.h .br /usr/include/linux/sys.h .br /usr/include/unistd.h .SH SEE ALSO kill(2), raise(3) .SH BUGS .B signal() and the code in sched.c, signal.c cannot correctly handle a SIG_DFL handler.