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.

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_DFL

This is the default Signal Handler

2 SIG_ERR

Performing a Signal Error

3 SIG_IGN

Ignore the signal

The SIG macro is used to represent a digital signal under the following conditions:

STTMacro & Description1 SIGABRT

End the program abnormally

2 SIGFPE

Error floating point number as divided by 0

3 SIGILL

Invalid operation

4 SIGINT

Interrupt signal, such as Ctrl-C

5 SIGSEGV

Invalid access to the repository

6 SIGTERM

Request to end

Functions defined in signal.h

Here are some functions defined in signal.h in Library C:

STD & Description1

Void function (* signal (int sig, void (* func) (int))) (int)

This function sets a function to handle the signal (eg a signal handler)

2

Function 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

5 ★ | 1 Vote