signal.h in C
signal.h in C
The header file named signal.h in Library C defines a type of variable sig_atomic_t, two function calls, and a number of macros to handle the different signals reported during execution of a program.
The variables are defined in signal.h
The following is the type of variable defined in signal.h:
sig_atomic_t : This is an int and is used as a variable in the signal handler. This is an integer type of an object that can be accessed as an atomic entity, even if there are asynchronous signals present.
The macros are defined in signal.h
The following are the macros defined in signal.h and these macros will be used in the two functions listed below. SIG_ macro is used with signal function to define signal functions.
TMTM & Description1 SIG_DFLThis is the default Signal Handler
2 SIG_ERRPerforming a Signal Error
3 SIG_IGNIgnore the signal
The SIG macro is used to represent a digital signal under the following conditions:
STTMacro & Description1 SIGABRTEnd the program abnormally
2 SIGFPEError floating point number as divided by 0
3 SIGILLInvalid operation
4 SIGINTInterrupt signal, such as Ctrl-C
5 SIGSEGVInvalid access to the repository
6 SIGTERMRequest to end
Functions defined in signal.h
Here are some functions defined in signal.h in Library C:
STD & Description1Void function (* signal (int sig, void (* func) (int))) (int)
This function sets a function to handle the signal (eg a signal handler)
2Function int raise (int sig)
This function generates a sig signal. The sig parameter is compatible with the SIG macro
According to Tutorialspoint
Previous article: Library C:
Next lesson: stdarg.h in C