Previous Next

Signal Masking

Signal masks can be examined and changed with the sigprocmask( ) function. When a synchronous signal is masked via a call to sigprocmask( ) it is masked for the calling thread. When an asynchronous signal is masked via a call to sigprocmask( ) it is masked for the entire process.

Care must be taken when a thread unblocks an asynchronous signal. If another thread has blocked and is, or is will be, waiting for the same signal, the results can be unpredictable and may result in the other thread waiting forever. This problem can be avoided by having all handling of asynchronous signals occur in a single thread, as described in Asynchronous Signal Handling .