Go to the previous, next section.
int sigaction(int signum, const struct sigaction *new,
struct sigaction *old);
(void *) (int) signal(int signum, (void *handler)(int));
signum: [in] a signal number.
new: [in] the action to take for this signal.
old: [out] the previous action that was associated to the signal.
handler: [in] points to the new signal handler.
sigaction
is used to specify the action to take in case the
signal signum is raised. signum can take one of the
following values:
SIGHUP
SIGINT
SIGQUIT
SIGILL
SIGTRAP
SIGABRT
abort
function.
SIGIOT
SIGUNUSED
SIGFPE
SIGKILL
SIGUSR1
SIGSEGV
SIGUSR2
SIGPIPE
SIGALRM
SIGTERM
SIGSTKFLT
SIGCHLD
SIGCONT
SIGSTOP
SIGTSTP
SIGTTIN
SIGTTOU
SIGIO
SIGPOLL
SIGURG
SIGXCPU
SIGXFSZ
SIGVTALRM
SIGPROF
SIGWINCH
SIGPWR
SIGBUS
There is also a signal SIGLOST
in the sources, however it is
commented out.
The action to take is specified by a sigcaction
structure that
has the following layout:
struct sigaction { __sighandler_t sa_handler; /* the handler (or a special value) */ sigset_t sa_mask; /* signals to block on entry */ int sa_flags; /* some flags */ void (*sa_restorer)(void); /* not used */ };
sa_handler
may be set to the address of the handler to start to
handle the signal or it may be set to one of the following special
values:
SIG_ING
SIG_DFL
sa_mask specifies signals to be added to the signal mask of the process before calling the signal handler. The signal mask is restored to its initial value upon return from the handler.
sa_flags specifies some options for the handling of the signal:
SA_NOCLDSTOP
SIGCHLD
signal when a child stops.
signum must be SIGCHLD
.
SA_RESTART
SA_STACK
SA_INTERRUPT
SA_NOMASK
SA_NODEFER
in [Stevens].)
SA_ONESHOT
SA_RESETHAND
in [Stevens].)
The previous value of the sigaction
structure for the signal is
stored to the area pointed to by old.
signal
is some kind of proto-sigaction
. It sets the
handler of signum to handler. It is equivalent to
struct sigaction new; new.sa_handler=handler; new.sa_mask=0; new.sa_flags=SA_NOMASK | SA_ONESHOT; new.sa_restorer=NULL; sigaction(signum, &new, NULL);
It could be implemented as a sigaction
wrapper.
On success, sigaction
returns zero and signal
returns the
pointer to the signal handler. On error, both return -1. The possible
values of errno
are:
EINVAL
: tried to set the handler of SIGKILL
or
SIGSTOP
.
EFAULT
.
Go to the previous, next section.