signal(2)
NAME
signal - ANSI C signal handling
SYNOPSIS
#include <signal.h>
typedef void (*sighandler_t)(int);
sighandler_t signal(int signum, sighandler_t action);
DESCRIPTION
The signal system call installs a new signal handler for
the signal with number signum. The signal handler is set
to handler which may be a user specified function, or one
of the following:
SIG_IGN
Ignore the signal.
SIG_DFL
Reset the signal to its default behavior.
The integer argument that is handed over to the signal
handler routine is the signal number. This makes it possi
ble to use one signal handler for several signals.
Signal handlers are called whenever the process receives
the corresponding signal. The default signal handler
behaviour varies among the different signals, these
behaviours are documented in signal(7).
RETURN VALUE
signal returns the previous value of the signal handler,
or SIG_ERR on error.
NOTES
Signal handlers cannot be set for SIGKILL or SIGSTOP.
Since libc6, signal uses BSD semantics and the default
behaviour is not reset when the signal is raised. You may
use sysv_signal to get SysV semantics.
Both signal and sysv_signal are library routines built on
top of sigaction(2).
According to POSIX, the behaviour of a process is unde
fined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal
that was not generated by the kill(2) or the raise(2)
functions. Integer division by zero has undefined result.
On some architectures it will generate a SIGFPE signal
(dividing the most negative integer by -1 may also gener
ate SIGFPE). Ignoring this signal might lead to an end
less loop.
According to POSIX (B.3.3.1.3) you must not set the action
for SIGCHLD to SIG_IGN. Here the BSD and SYSV behaviours
differ, causing BSD software that sets the action for
SIGCHLD to SIG_IGN to fail on Linux.
The use of the sighandler_t is a GNU extension, and the
type is only present when _GNU_SOURCE is defined.
CONFORMING TO
ANSI C
SEE ALSO
kill(1), kill(2), killpg(2), pause(2), raise(3), sigac
tion(2), signal(7), sigsetops(3), sigvec(2), alarm(2)
Man(1) output converted with
man2html