Applications are provided with various APIs for managing signals; we shall take a look at few of the important ones:
- Sigaction(): User-mode processes use the POSIX API sigaction() to examine or change the disposition of a signal. This API provides a variety of attribute flags that can further define the behavior of a signal:
#include <signal.h>
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
The sigaction structure is defined as something like:
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
- int signum is the identifier number of a recognized signal. sigaction() examines and sets the action to be associated with this signal.
- const struct sigaction *act can be assigned with the address of a struct sigaction...