sigprocmask()¶
Purpose¶
sigprocmask() changes the calling thread's signal mask.
It is commonly used before signalfd() so selected signals are delivered through a file descriptor instead of traditional handlers.
Header¶
Prototype¶
Minimal Example¶
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) {
perror("sigprocmask");
return -1;
}
Common Pitfalls¶
- Creating a
signalfdwithout blocking the same signals first. - Blocking signals globally without documenting shutdown behavior.
- Confusing process signal disposition with per-thread signal masks.