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 ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.