Standard C++ Library Reference ISO/IEC (VERSION3)
Next
<signal.h>
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:
make calls (that succeed) to the function signal●
assign values to objects of type volatile sig_atomic_t●
return control to its caller●
Furthermore, in C++, a signal handler should:
have extern "C" linkage●
use only language features common to C and C++●
If 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.
/* MACROS */
#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>