Skip navigation.
Home

How to block and unblock signals

sigBlock.c   Demonstrates how to block and unblock signals. A signal does not die when it is blocked. It hangs around until such a time that the process unblocks it. This may or may not happen. (Some signals, such as SIGKILL cannot be blocked or ignored.) A signal does die if the handler is set to SIG_IGN.

Unless you are doing real-time signal handling with sigqueue, Linux uses a bitmap to know what signals have been sent to a process. One bit per signal. In this model, if the same signal (such as SIGINT) is sent multiple times while that signal's bit is set, the bitmap does not change. It is as if the signal was sent only once. The bit will be cleared once the process deals with the signal. That may be to call a function, ignore it, or take the default action. If that signal is blocked, it is not delivered to the process until it is unblocked.