Reputation: 14428
For theory purpose: I associate handler for SIGINT, by using signal (). When the this signal is handled, ie, signal handler is executed, by default the same signal is blocked. What is the reason behind blocking ?. Does it lead to deadlock kind of situation ? Kindly clarify.
Upvotes: 3
Views: 670
Reputation: 1
Because signal handlers are not expected to be re-entrant.
A signal handler typically runs quickly and should call only async safe functions, i.e. a very restricted set of functions, see signal(7).
You usually don't want it to be callable inside itself.
Unless you don't return normally from the signal (or do a siglongjmp
inside it), the previous signal masks are restored after the signal handler completed.
However, you can install a signal handler (thru sigaction
) which does not block itself.
For similar reasons, on usual processors, the intterupt handlers are also running quickly and are disabling interrupts.
Upvotes: 4