Signal masks
Each signal has one of three possible states:
- For the signal, we might have our own signal handler.
- The default handler may be used to handle a signal. Each signal has a default handler job that it performs. For instance, your application will be terminated by the SIGINT default handler.
- The signal could be overlooked. Signal blocking is another name for ignoring a signal.
It is frequently simpler to handle a “signal mask” when manipulating signals and controlling signal setup. Each bit in a bit-mask has a matching signal. Since there are 32 (really 31, since 0 doesn’t count) different signals, we can store information about 32 signals in a single 32-bit integer (unsigned int).
The operating system does exactly this. Signal masks are also utilized as arguments in other system calls, so we will need to work with them. Default signal handlers are assigned by the C library. This means that even if you ignore signals, your software will still process them and act on them as it would normally.
Signal Handling In Linux Through The signal() Function
A signal is a message or notification issued to your program by the operating system or another application (or one of its threads). Each signal is assigned a number between 1 and 31. Signals are devoid of argument, and most of the time, their names are self-explanatory. For instance, signal number 9 or SIGKILL notifies the program that it is being attempted to be killed.