If a process receives a signal that it is currently blocking, that signal is added to the process’s set of pending signals. When (and if) the signal is later unblocked, it is then delivered to the process. To determine which signals are pending for a process, we can call sigpending().
#include <signal.h>
int sigpending
(sigset_t *set);
Returns 0 on success, or -1 on error
The sigpending() system call returns the set of signals that are pending for the calling process in the sigset_t structure pointed to by set. We can then examine set using the sigismember() function described in Section 20.9.
If we change the disposition of a pending signal, then, when the signal is later unblocked, it is handled according to its new disposition. Although not often used, one application of this technique is to prevent the delivery of a pending signal by setting its disposition to SIG_IGN
, or to SIG_DFL
if the default action for the signal is ignore. As a result, the signal is removed from the process’s set of pending signals and thus not delivered.