If a process is currently stopped due to a SIGTRAP signal and it is sent a SIGSTOP signal via kill(), what would be the default behavior? Would the SIGSTOP be a pending signal that is delivered after the process continues again? Or will it just be discarded/ignored?
If the SIGSTOP is queued up, is there any way to remove it from the queue from outside of that process, such as in a tracing process?
POSIX Signal Handling In modern POSIX, the Ublock in each process has a signal table (recall the previous post), which conceptually is a set of [signal/action] pair. For each signal in the reserved set, there is a corresponding default action that is usually “ignore” or “terminate” (see details on man page).
Certain POSIX signals do not go through the condition handling steps described above: SIGKILL and SIGSTOP cannot be caught or ignored; they always take effect. SIGCONT immediately begins all stopped threads in a process if SIG_DFL is set.
The SIGTERM signal is sent to a process to request its termination. Unlike the SIGKILL signal, it can be caught and interpreted or ignored by the process.
The signal() function does not (necessarily) block other signals from arriving while the current handler is executing; sigaction() can block other signals until the current handler returns. The signal() function (usually) resets the signal action back to SIG_DFL (default) for almost all signals.
From the signal(7) man page:
The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
A simple test with an app stopped on a breakpoint and sending it a SIGSTOP
shows gdb displaying some information when I hit 'next'. The signal was obviously delivered to the app. It cannot continue to be debugged until I send it a SIGCONT
.
(gdb) next
Program received signal SIGSTOP, Stopped (signal).
fill (arr=0x7fffffffdff0, size=5) at tmp.cpp:28
(gdb) next
Program received signal SIGCONT, Continued.
fill (arr=0x7fffffffdff0, size=5) at tmp.cpp:28
(gdb) next
(gdb)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With