#include
#include
static volatile sig_atomic_t being_debugged = 1;
static void int3_handler(int signo) { being_debugged = 0; }
in
GDB will stop the inferior (being debugged) program when the inferior receives any signal.
If you simply continue
from GDB, the signal will be "swallowed", which is not what you want.
You can ask GDB to continue the program and send it a signal with signal SIGTRAP
.
You can also ask GDB to pass a given signal directly to the inferior, and not stop at all with handle SIGTRAP nostop noprint pass
GDB command. You'll need to do that before you hit the first SIGTRAP
.