I’m trying to figure out how to block a signal in Linux kernel 2.4 (user space) from invoking its handler, but keep it available to be handled later, preferably as soon as I re activate the handling of said signal.
The function sigprocmask seem to come up in all my search results, but I can’t find a good, clear description that explains whether the blocked signal gets “saved” to be handled later, and if so where and how do I handle it when I’m ready for it.
Can someone please clarify what’s going on, preferably with a code example?
Thanks in advance.
I really can’t say it better than the
signal(7)man page:So, you can block and unblock the signal with
sigprocmask(). If the signal is raised while it’s blocked, the handler won’t be called until it’s unblocked. If a signal is pending when it’s unblocked, the handler for the signal will be called as usual.Note that a given signal is either pending or not; it can’t be “pending twice” (or more). if the signal is raised twice while it is blocked, it’ll still only be delivered once.