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: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?
Are multiple signals given to a process served sequentially or their signal handler can cascade?
linux;kernel