[Mac OS X] Avoid the SDL to catch SIGTERM and SIGINT signals

Hello all,

SHORT QUESTION :
On Mac OS X, is there a way to prevent the SDL to catch SIGTERM and SIGINT, that is to let CTRL+C kill the program in the Terminal, when no event loop is running ?

Apparently

  SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1");

has no effect on the Mac.

LONGER, with context :
I am using SDL2 in a programming teaching context, only to display images in C programs in a portable dev context.

I do not want any even loop.
I do know this is not standard. In fact, on the Mac, I do have to call SDL_PollEvent a few times to ensure the created window is actually displayed…
But for my student having an event loop is not the way to go (they are new to C and programming).

Still, I need them to CTRL-C their program from the Terminal.

APparently

  SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1");

has no effect on the Mac (though Mac is a “Unix-like platforms” as mentioned in the doc).

This is the reason for my today’s question :
On Mac OS X, is there a way to prevent the SDL to catch SIGTERM and SIGINT, that is to let CTRL+C kill the program in the Terminal when no event loop is running ?

I thank you all VERY much, for the SDL, and for your upcoming help,
Nicolas

Are you setting that hint before SDL_Init()? If so, that should work.

Huge ! That solves the issue. Thanks !

This could be added to the documentation of SDL_SetHint() or of SDL_HINT_NO_SIGNAL_HANDLERS.
I can contribute it, but where should I act and commit ?

1 Like

Added, thanks!
https://hg.libsdl.org/SDL/rev/82e1e144c03b