Describe how a process can handle signals in Linux. What are the possible actions a process can take when a signal is delivered, and how can a signal handler function be set up using the signal() function?
When a signal is sent to a process the process's normal flow of execution is interrupted.
The possible actions taken by the os are:-
Default action: Each signal has a default action, such as terminating the process, which is taken if no other process is identified.
Ignore: The process can choose to ignore the signal.
Catch: The process can catch the signal and execute a custom signal handler function.
Signal handler is executed in response to a specific signal. When a signal is caught the process temporarily stops executing its current code and runs the signal handler function. Using the signal function we specify the signal to be used and also as the second argument pass the signal handler.