C Standard Library - <signal.h>
Introduction
signal.h The header file defines a variable type sig_atomic_t, two function calls and some macros to handle reporting during program execution of different signals.
Library variables
The following are the variable types defined in the header file signal.h:
Serial number | Variables & Description |
---|---|
1 | sig_atomic_t This is the int type, used as a variable in a signal handler . It is an integer type of an object that can be accessed as an atomic entity even in the presence of asynchronous signals. |
Library macros
The following are the macros defined in the header file signal.h. These macros will be used in the following two functions. SIG_ Macros are used with the signal function to define the functionality of a signal.
Serial Number | Macro & Description |
---|---|
SIG_DFLDefault signal handler. | |
SIG_ERR indicates a signal error. | |
SIG_IGNIgnore the signal. |
SIG Macro is used to represent the signal number of the following conditions:
Macro & Description | |
---|---|
SIGABRTThe program terminated abnormally. | |
SIGFPEAn arithmetic operation error occurred, such as division by 0 or overflow. | |
SIGILLIllegal function image, such as illegal instruction. | |
SIGINTInterrupt signal, such as ctrl-C. | |
SIGSEGVIllegal access to memory, such as accessing a non-existent memory unit. | |
SIGTERMThe termination request signal sent to this program. |
Function & Description | |
---|---|
void (*signal(int sig, void (*func)(int)))(int) | This function sets a function to handle the signal, that is, the signal handler. |
int raise(int sig) | This function will cause the signal sig to be generated. The sig parameter is compatible with the SIG macro. |