Wednesday, July 05, 2006

Unreliable Signals

So, something interesting about signals in Unix system.
Reliable signal delivery
Suppose user install a handler for a particular signal, and this signal is caught, the kernel would reset the handler to the default handler rather than the user specified handler, then invoke the user specified handler. So if the user want to catch the same signal multiple times, the user specified handler needs to be reinstall every time the signal is caught.
If two signal of the same kind happen at the same time, the first signal would trigger the user specific handler, before the user specific handler is invoked, the
system would reset the signal handler to default handler rather than the user specific handler. Now the second signal is caught, the system would trigger the default handler and this would void the user handler and defeat the whole purpose of having a user specific handler.

No comments: