Signal is a very important mode of communication in the operating system. In recent versions, there have been few major changes in signal processing. We analyze the signal implementation of the Linux kernel from the user space signal application.
One: signal-related data structure
The structure of the signal in the task_struct:
struct Task_struct {
...
Pointing to the process signal descriptor
struct signal_struct *signal;
The processing descriptor of the signal is
struct sighand_struct *sighand;
The mask of blocking signal
sigset_t blocked, real_blocked;
The saved signal mask. When defining tif_restore_sigmask, restore the signal mask
sigset_t saved_sigmask; /* To is restored with tif_restore_sigmask/
//storage of hung signal
struct sigpending pending;
Specifies the stack address of the signal handler
unsigned long sas_ss_sp;
The stack size of the signal processing program is
size_t sas_ss_size;
A pointer to a function that the device drives to block some signal
int (*notifier) (void *priv) of the process;
The parameter void *notifier_data of the notifier ()
;
The driver passes the bitmap sigset_t *notifier_mask of the signal blocked by notifier ()
;
...
}