What is the sigaction function and how does it provide more control over signal handling compared to the signal function? Describe its syntax and the purpose of its parameters.
The sigaction function provides more robust and flexible way of handling as compared to signal function ,
It allows to specify the signal handler function, signals to block during the execution of the handler, flags to modify the behavior of signal handling.
struct sigaction
{
void (*sa_handler)(int); //pointer to the signal handler function
void (*sa_sigaction)(int,siginfo_t* ,void*); //pointer to the signal handling function with extended information
sigset_t sa_mask; //set of signals to be blocked during the execution of the handler
int sa_flags; //flags to modiy the behavior of the signal
void (*sa_restorer)(void); //used earlier, obsolete now
};
sa_handler
Its syntax is (void)(*sa_handler)(int)
This is a pointer to a signal handler function that takes a single integer paramter, which is the signal number.
sa_sigaction
its syntax is (void*)(sa_sigaction)(int,siginfo_t *,void *)
This is a pointer to a signal handler function that provides extended information about the signal.