4

I was developing my own signal handling mechanism in User space. when browsing the kernel code and executing some c-code. I realized,

  • Scenario 1 : When my code is executing a signal handler on receipt of signal, and let's say a new signal of different type is encountered(this new signal is also handled), the new signals signal handler (SH2) gets invoked saving the context of already executing signal handler (SH1). Once SH2 completes, SH1 again its execution from where it left.

  • Scenario 2 : I registered handler for four signals SIGINT, SIGUSR2, SIGHUP. I then blocked all these signals and generated these signals using "kill" command from terminal. After which i again unblocked these signals. What i observed was, these signals were delivered sequentially, their handlers got executed sequentially.

So when does signal handlers get executed sequentially and when are they cascaded.

I browsed kernel source:

  1. when a signal is generated, it gets added in the pending list and TIF_SIGPENDING flag is set. On schedule timer interrupt, this flag is checked(I am not sure on this), which leads the execution of do_signal() which dequeues the signal and recalculate TIF_SIGPENDING flag. If there are more signals in pending list this flag is set again.

If now the scheduler timer expires the new signal handler will be invoked(leading to cascading of signal handler) Then how does the signal handler execute sequentially in some cases?

  • That would be an interesting (and complex) question for stackoverflow – Ring Ø Nov 29 '17 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.