In your specific example (the same signal is received), the signal is delivered after the signal handler has finished processing (so that point number 2 is correct). Please note, however, that you may “lose” signals.
The reason for this is that although the signal is inside its handler, it is blocked. Blocked signals are set on hold, but not in the queue. The term “waiting” means that the operating system remembers that there is a signal waiting to be delivered at the next opportunity, and “not queued” means that it does this by setting the flag somewhere, but not keeping an accurate record of how it appeared a lot of signals.
That way, you can get 2 or 3 (or 10) more SIGCHLD while in your handler, but you only see one (so in some cases the number 1 mark may also be correct).
Please note that several flags that you can pass to sigaction can influence the default behavior, for example, SA_NODEFER (prevents a blocking signal) and SA_NOCLDWAIT (may not generate a signal at all on some systems).
Now, of course, if you receive a different type of signal, there is no guarantee that it will not interrupt your handler. For this reason, one prefers not to use safe functions without a signal.
Damon source share