Article Title: Pending signals and blocked signals. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Signal status:
The "pending" Status of the signal refers to the period from the generation of the signal to the time before the signal is processed;
The "blocking" of a signal is a switch action that prevents the signal from being processed, but does not prevent the signal from being generated.
The example of APUE blocks the exit signal with sigprocmask before sleep, then sleep, and generates an exit signal during sleep, but the exit signal is blocked at this time, ("blocking" in Chinese is easy to be misunderstood as a State. It is actually a switch-like action, so "blocked" rather than "blocked ") so it is in the pending status. After sleep, use sigprocmask to turn off the blocking switch of the exit signal, because the exit signal generated previously remains in the pending status. When the blocking switch is closed, exit the "pending" status immediately and get processed. This happens before sigprocmask returns.
Conclusion: blocked signals are not discarded, but not processed. This status is called the pending status.
After blocking is removed, signals in the pending status will be processed.
Call sigprocmask to remove blocking, but the blocking action is completed before sigprocmask returns.
The pending signal processing is required before the function sigprocmask returns.
Int sigpend (sigset_t * set); --- obtain the pending signal.
Int sigprocmask (int how, const sigset_t * set, sigset_t * oset );
---- Depending on the value of how, it is the completed action, blocking, and blocking relief.
Note: The pending signals cannot be the same. If the signal is generated
Once and once again, it will be discarded.
Of course, if it is a real-time signal, it is another matter. Because real-time signals can have multiple identical pending signals.