SIGNAL(2) SIGNAL(2)
signal - software signal facilities (System V)
#include <signal.h>
C:
void (*signal (int sig, void (*func)()))();
C++:
void (*signal (int sig, void (*func)(int)))(int);
#if _XOPEN_SOURCE
void (*signal (int sig, void (*func)(int)))(int);
#endif
signal allows the calling process to choose one of three ways in which it
is possible to handle the receipt of a specific signal. sig specifies
the signal and func specifies the choice.
For a list of valid signals and a general description of the signal
mechanism please see signal(5).
[EINVAL] signal will fail if sig is an illegal signal number, including
SIGKILL and SIGSTOP.
[EINVAL] signal will fail if an illegal operation is requested (for
example, ignoring SIGCONT, which is ignored by default).
kill(1), intro(2), blockproc(2), kill(2), pause(2), ptrace(2),
sigaction(2), sigset(2), wait(2), setjmp(3C), sigvec(3B),
pthread_kill(3P), signal(5)
Upon successful completion, signal returns the previous value of func for
the specified signal sig. Otherwise, a value of SIG_ERR is returned and
errno is set to indicate the error. SIG_ERR is defined in the header
file <sys/signal.h>.
Signals raised by any instruction in the instruction stream, including
SIGFPE, SIGILL, SIGEMT, SIGBUS, and SIGSEGV, will cause infinite loops if
their handler returns, or the action is set to SIG_IGN. This is because
the exception PC at the time of the signal points to the instruction that
raised the exception or signal, and resuming the process will re-execute
that same instruction.
The POSIX signal routines (sigaction(2), sigpending(2), sigprocmask(2),
sigsuspend(2), sigsetjmp(3)), and the 4.3BSD signal routines (sigvec(3B),
signal(3B), sigblock(3B), sigpause(3B), sigsetmask(3B)) must NEVER be
used with signal(2) or sigset(2).
Page 1
SIGNAL(2) SIGNAL(2)
Before entering the signal-catching function, the value of func for the
caught signal will be set to SIG_DFL unless the signal is SIGILL,
SIGTRAP, or SIGPWR. This means that before exiting the handler, a signal
call is necessary to again set the disposition to catch the signal.
Note that handlers installed by signal execute with no signals blocked,
not even the one that invoked the handler.
PPPPaaaaggggeeee 2222 [ Back ]
|