<signal.h>#define SIGABRT <integer constant expression >= 0> #define SIGFPE <integer constant expression >= 0> #define SIGILL <integer constant expression >= 0> #define SIGINT <integer constant expression >= 0> #define SIGSEGV <integer constant expression >= 0> #define SIGTERM <integer constant expression >= 0> #define SIG_DFL <address constant expression> #define SIG_ERR <address constant expression> #define SIG_IGN <address constant expression> int raise(int sig); typedef i-type sig_atomic_t; void (*signal(int sig, void (*func)(int)))(int);
Include the standard header <signal.h>
to specify how the program handles signals
while it executes. A signal can report some exceptional behavior
within the program, such as division by zero. Or a signal can
report some asynchronous event outside the program, such as
someone striking an interactive attention key on a keyboard.
You can report any signal by calling raise. Each
implementation defines what signals it generates (if any) and
under what circumstances it generates them. An implementation can
define signals other than the ones listed here. The standard
header <signal.h> can define additional macros
with names beginning with SIG to specify the values
of additional signals. All such values are integer constant
expressions >= 0.
You can specify a signal handler
for each signal. A signal handler is a function that the target
environment calls when the corresponding signal occurs. The
target environment suspends execution of the program until the
signal handler returns or calls longjmp.
For maximum portability, an asynchronous signal handler should
only:
signalsig_atomic_tFurthermore, in C++, a signal handler should:
extern "C" linkageIf the signal reports an error within the program (and the
signal is not asynchronous), the signal handler can terminate by
calling abort, exit, or longjmp.
SIGABRT#define SIGABRT <integer constant expression >= 0>
The macro yields the sig argument value for the
abort signal.
SIGFPE#define SIGFPE <integer constant expression >= 0>
The macro yields the sig argument value for the
arithmetic error signal, such as for division by zero or result
out of range.
SIGILL#define SIGILL <integer constant expression >= 0>
The macro yields the sig argument value for the
invalid execution signal, such as for a corrupted function image.
SIGINT#define SIGINT <integer constant expression >= 0>
The macro yields the sig argument value for the
asynchronous interactive attention signal.
SIGSEGV#define SIGSEGV <integer constant expression >= 0>
The macro yields the sig argument value for the
invalid storage access signal, such as for an erroneous lvalue
expression.
SIGTERM#define SIGTERM <integer constant expression >= 0>
The macro yields the sig argument value for the
asynchronous termination request signal.
SIG_DFL#define SIG_DFL <address constant expression>
The macro yields the func argument value to signal
to specify default signal handling.
SIG_ERR#define SIG_ERR <address constant expression>
The macro yields the signal return value
to specify an erroneous call.
SIG_IGN#define SIG_IGN <address constant expression>
The macro yields the func argument value to signal
to specify that the target environment is to henceforth ignore
the signal.
raiseint raise(int sig);
The function sends the signal sig and returns
zero if the signal is successfully reported.
sig_atomic_ttypedef i-type sig_atomic_t;
The type is the integer type i-type for
objects whose stored value is altered by an assigning operator as
an atomic operation (an
operation that never has its execution suspended while partially
completed). You declare such objects to communicate between signal
handlers and the rest of the program.
signalvoid (*signal(int sig, void (*func)(int)))(int);
The function specifies the new handling for signal sig
and returns the previous handling, if successful; otherwise, it
returns SIG_ERR.
func is SIG_DFL,
the target environment commences default handling (as
defined by the implementation). func is SIG_IGN,
the target environment ignores subsequent reporting of
the signal. func must be the address of a
function returning void that the target
environment calls with a single int argument. The
target environment calls this function to handle the
signal when it is next reported, with the value of the
signal as its argument. When the target environment calls a signal handler:
longjmp, or
calls signal for that signal. SIGILL, the
target environment can leave handling unchanged for that
signal. See also the Table of Contents .
Copyright © 1989-1996 by P.J. Plauger and Jim Brodie. All rights reserved.