Deferring signal handling in Linux -


I'm trying to figure out how to block the signal from opening your handler in Linux kernel 2.4 (user space) But to be ready to handle it later, preferably as soon as I am activating the handling of the signal.

The function sigprocmask comes in all my search results, but I am not getting a good, clear description that indicates that the blocked signal is "saved" to be handled later, and if so And then when I'm ready for it, how do I manage it?

Can anyone explain what is happening, preferably with a code example? Thanks in advance.

I can not really say it better than signal (7) Page:

A sign can be blocked , which means that it will not be given until it is unblocked later. It is called pending when it is generated and when it is indicated.

In each process, each thread is an independent signal mask, which indicates that the thread is currently blocked by using a thread pthread_sigmask (3) to manipulate its signal mask Could. In a traditional single-threaded application, sigprocmask (2) can be used to manipulate the signal mask.

So, you can block and unblock the signal sigprocmask () . If the signal is lifted on the block, the handler will not be called until it is unblocked. If a signal is pending, when it is unblocked, the handler for the signal will be called in normal form.

Note that if an indication is either pending either or not; It can not be "twice pending" (or more). If the signal is raised twice, while it is blocked, it will still be distributed only once.


Comments