According to this site , a blocked / ignored signal is automatically unlocked inside the kernel code when it is raised. Therefore, if the same signal is repeated repeatedly, an infinite loop will not occur. Instead, the application terminates at a second signal boost, at least in the Linux kernel implementation.
Therefore, when using raise() , the SIGTRAP value will only go up once, without causing problems. But with asm("int3") processor will restart the instruction that raised the signal. The second time this leads to the completion of the process.
The corresponding kernel source (for old 2.6.27) is here (function force_sig_info):
939 if (blocked || ignored) { 940 action->sa.sa_handler = SIG_DFL; 941 if (blocked) { 942 sigdelset(&t->blocked, sig); 943 recalc_sigpending_and_wake(t); 944 } 945 }
Chris source share