Querying the signal mask
So, we understand that you can set the process's signal mask at the time of sigaction(2) (via the sa_mask member), or via the sigprocmask(2) system call (as mentioned previously). But how exactly can you query the state of the process signal mask at any arbitrary point in time?
Well, again, via the sigprocmask(2) system call. But, logically, this API sets a mask, right? This is the trick: if the first parameter set is set to NULL, then the second parameter is effectively ignored, while in the third parameter oldset, the current signal mask value is populated, and thus we can query the signal mask without altering it.
The ch11/query_mask program demonstrates this, the code is built upon our previous example sig2.c ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access