![]() |
![]() |
![]() |
Modify or examine the signal blocked mask of a thread
#include <sys/neutrino.h> int SignalProcmask( pid_t pid, int tid, int how, const sigset_t* set, sigset_t* oldset ); int SignalProcmask_r( pid_t pid, int tid, int how, const sigset_t* set, sigset_t* oldset );
libc
The SignalProcmask() and SignalProcmask_r() functions are identical except in the way they indicate errors. See the Returns section for details.
These kernel calls modify or examines the signal blocked mask of the thread tid in process pid. If pid is zero, the current process is assumed. If tid is zero, pid is ignored and the calling thread is used.
If the value of set isn't NULL, it points to a set of signals to be used to change the currently blocked set. The value of how indicates the manner in which the set is changed:
As a special case, the how argument can be used to query the current set of pending signals:
If the value of oldset isn't NULL, the previous blocked mask is saved there. The combination of set and oldset allows you to query or change (or both) the signal blocked mask for a signal.
When a signal is unmasked, the kernel checks for pending signals on the thread and, if there are none pending, on the process:
Check | Action |
---|---|
Signal pending on thread | The signal is immediately acted upon. |
Signal pending on process | The signal is moved to the thread and is immediately acted upon. |
No signal pending | No signal action performed until delivery of an unblocked signal. |
It isn't possible to block the SIGKILL or SIGSTOP signals.
When a signal handler is invoked, the signal responsible is automatically masked before its handler is called (see SignalAction()). If the handler returns normally, the operating system restores the signal mask present just before the handler was called as an atomic operation. Changes made using SignalProcmask() in the handler are undone.
When a signal is targeted at a process, the kernel delivers it to at most one thread (see SignalKill()) that has the signal unblocked. If multiple threads have the signal unblocked, only one thread is given the signal. Which thread receives the signal isn't deterministic. To make it deterministic, you have two choices:
If all threads have the signal blocked, it's made pending on the process. The first thread to unblock the signal receives the pending signal. If a signal is pending on a thread, it's never retargetted to the process or another thread, regardless of changes to the signal-blocked mask.
Signals targeted at a thread always affect that thread alone.
These calls don't block.
The only difference between these functions is the way they indicate errors:
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
![]() |
![]() |
![]() |