The sa _ handler field should be set as a pointer to a previously declared
function that looks like this:
void user_handler (int signum)
{
// signal processing
}
This feature becomes a signal processor. The signum parameter determines
which signal is sent to the handler (the same handler can be logged for
multiple signals by several sigaction () calls ). After logging in, the handler
will always be called when it receives the appropriate signal:
#include
void sigint_handler (int signum)
{
// SIGINT processing
}
// …… ..
action.sa_handler = sigint_handler;
sigaction (SIGINT, & action, 0);
If we need to organize the wait for the signal, the simplest way is to open a
system call pause (). In this case, the process enters standby mode, from
which it will output any signal:
// ask the handlers for help with sigaction ()
pause (); // wait for a signa l