SIGPROCMASK(2)

πŸ’… sigprocmask(2) β€” the system calls manual, bestie edition

okay so this is a page from the System Calls Manual (section 2, iykyk) and it's all about sigprocmask πŸŽ€


✨ NAME ✨

sigprocmask β€” manipulate current signal mask

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc)

🌸 SYNOPSIS 🌸

#include <signal.h>

int
sigprocmask(int how, const sigset_t * restrict set,
    sigset_t * restrict oset);

πŸ’– DESCRIPTION πŸ’–

so the sigprocmask() system call literally examines and/or changes the current signal mask β€” that's the lil set of signals that are blocked from delivery πŸ’€. A signal is blocked if it's a member of the current signal mask set. that's it, that's the vibe.

If set is not null, what sigprocmask() actually does depends on the value of the how argument. The signal mask gets changed as a function of the specified set and the current mask. You pick the function with how, using one of these values from <signal.h>:

  • SIG_BLOCK β€” the new mask is the union of the current mask and the specified set. (adding stuff to the blocklist, main character behaviour 🫢)
  • SIG_UNBLOCK β€” the new mask is the intersection of the current mask and the complement of the specified set. (unblocking, we love a glow-up ✨)
  • SIG_SETMASK β€” the current mask is replaced by the specified set. full replacement, no notes πŸ”₯

If oset is not null, it gets set to the previous value of the signal mask. And when set is null, the value of how is insignificant and the mask remains unset β€” which gives you a way to examine the signal mask without modifying it. peek but don't touch, we stan πŸ™ˆ

The system quietly disallows SIGKILL or SIGSTOP to be blocked. no cap. those two are simply not blockable, periodt.
⚠️ In threaded applications, pthread_sigmask(3) must be used instead of sigprocmask(). like, must must. don't come crying to me πŸ’€

πŸ¦‹ RETURN VALUES πŸ¦‹

The sigprocmask() function returns the value 0 if successful πŸŽ‰; otherwise the value -1 is returned and the global variable errno is set to indicate the error 😭.


⭐ ERRORS ⭐

The sigprocmask() system call will fail and the signal mask will be unchanged if one of the following occurs:

  • [EINVAL] β€” the how argument has a value other than those listed here. (bestie. you had three options. three. πŸ’€)

πŸ‘‘ SEE ALSO πŸ‘‘

kill(2), sigaction(2), sigpending(2), sigsuspend(2), fpsetmask(3), pthread_sigmask(3), sigsetops(3)


🌈 STANDARDS 🌈

The sigprocmask() system call is expected to conform to ISO/IEC 9945-1:1990 (β€œPOSIX.1”). certified iconic, compliant, and unbothered ✨


and that's the whole page, bestie πŸ’œ this one's from the Debian fam, dated May 7, 2010 β€” so yes she's a little vintage, but she still serves. mwah πŸ’… πŸŽ€

πŸ“¦ where this page comes from