<signal.h> Signal Handling

The header file signal.h consists of a type, several macros and two functions that specify how the program handles signals while it is executing. A signal is a condition that may be reported during the program execution. Signals are synchronous, occurring under software control via the raise function.

A signal may be handled by:

By default, all signals are handled by the default handler, which is identified by SIG_DFL.

The type sig_atomic_t is an integer type that the program accesses atomically. When this type is used with the keyword volatile, the signal handler can share the data objects with the rest of the program.

The following type is included in signal.h.

sig_atomic_t - A type used by a signal handler. Prototype: typedef int sig_atomic_t;

The following argument and return value macros is included in signal.h.

SIG_DFL - Used as the second argument and/or the return value for signal to specify that the default handler should be used for a specific signal.

SIG_ERR - Used as the return value for signal when it cannot complete a request due to an error.

SIG_IGN - Used as the second argument and/or the return value for signal to specify that the signal should be ignored.