Comment

Comment by o11c

Don't mess around with silly tricks like that. Do it the proper way:

    #include <signal.h>
    
    int main()
    {
        signal(SIGTRAP, SIG_IGN);
        raise(SIGTRAP);
    }
When outside a debugger, the `raise`d signal will be ignored (of course, if you want a coredump you can remove the `signal` line).

When inside a debugger, requests to ignore `SIGTRAP` have no effect, unlike other signals. That's because this is literally what `SIGTRAP` is for.

parent o11c 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton