What is the sigaction function and how does it provide more robust and flexible signal handling compared to the signal() function? Describe the structure and key fields of struct sigaction.
The sigaction function provides more robust and flexible way of handling as compared to signal function as we can specify more options and control the behavior of signal handling more precisely. The sigaction structure looks as:-
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