Signal masking with the sigprocmask API

What if we want to block (or mask) some other signals during execution. For example, while processing a critical region of code? The system call sigprocmask(2) is designed for this purpose:  int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);

The signal sets are essentially bitmasks of the signals in question. The set is the new set of signals to mask, while oldset is actually a return value (the value-result type of parameter), or the previous (or current)  value of the signal mask. The how parameter determines the behavior and can take these values:

  • SIG_BLOCK : Additionally, block (mask) the signals specified in the signal set set (along with the signals already masked)
  • SIG_UNBLOCK : Unblock (unmask) the signals specified in the signal set set
  • SIG_SETMASK : The signals specified in the signal set set are masked, overwriting the previous values
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset