What happens if a process gets a signal after it was stopped by SIGSTOP
?
I am trying to understand and get a good picture of how this is handled. Unfortunately, all I could find was a short description of the signal but no details of particular use-cases.
As of now, my understanding is that while SIGSTOP
is in effect:
SIGKILL
will kill the process immediately- other signals will be gathered up, and on a
SIGCONT
, the signals on hold will be unleashed on the process, as if all of them were sent at that moment - while handling the bunched-up signals after a
SIGCONT
,sa_mask
,sa_flags
'sSA_RESTART
, etc. will be applied, as per normal
E.g., If there is a SIGSTOP
-> SIGHUP
-> SIGCONT
sequence, the handling of SIGHUP
will be put on hold until after SIGCONT
is received.
I am not sure if that is correct.
I am still in the dark about these cases:
I am still confused about the order of the bunched-up signals.
E.g.:
SIGSTOP
->SIGHUP
->SIGTERM
->SIGCONT
: willSIGHUP
andSIGTERM
be handled in the order they are received, or in an arbitrary order?What happens if the same signal is received multiple times while
SIGSTOP
is in effect?SIGSTOP
->SIGHUP
->SIGHUP
->SIGCONT
Will
SIGSTOP
interrupt a running signal handler? If signals were waiting to be handled, are they preserved until after aSIGCONT
?
I have found some answers in the answers to these similar questions, but I am still unclear on the above things.
SIGCHLD
, there is at least one child process that has changed its state. Your code should be prepared to handle more than one related event when a signal is received. – Bodo May 02 '22 at 17:17SIGCHLD
is part of my reply to your question "What if there were multiple signals of the same type?" as an example for "Signals are not queued." I chose this signal because the meaning ofSIGCHLD
and the expected reaction of the program are more or less fixed. The meaning of other signals might depend on your specific program, so without seeing your source code I can not give a better example. – Bodo May 03 '22 at 12:32