7.14 Signal handling <signal.h>

1

The header <signal.h> declares a type and two functions and defines several macros, for handling various signals (conditions that may be reported during program execution).

2

The type defined is

sig_atomic_t

which is the (possibly volatile-qualified) integer type of an object that can be accessed as an atomic entity, even in the presence of asynchronous interrupts.

3

The macros defined are

SIG_DFL
SIG_ERR
SIG_IGN

which expand to constant expressions with distinct values that have type compatible with the second argument to, and the return value of, the signal function, and whose values compare unequal to the address of any declarable function; and the following, which expand to positive integer constant expressions with type int and distinct values that are the signal numbers, each corresponding to the specified condition:

SIGABRT        abnormal termination, such as is initiated by the abort function
SIGFPE         an erroneous arithmetic operation, such as zero divide or an operation
               resulting in overflow
SIGILL         detection of an invalid function image, such as an invalid instruction
SIGINT         receipt of an interactive attention signal
SIGSEGV        an invalid access to storage
SIGTERM        a termination request sent to the program

4

An implementation need not generate any of these signals, except as a result of explicit calls to the raise function. Additional signals and pointers to undeclarable functions, with macro definitions beginning, respectively, with the letters SIG and an uppercase letter or with SIG_ and an uppercase letter,[1] may also be specified by the implementation. The complete set of signals, their semantics, and their default handling is implementation-defined; all signal numbers shall be positive.

Footnotes