I'm trying to port some C software to win32 but I don't know how to handle the SIGQUIT signal. I checked the signal.h of Mingw and it doesn't support SIGQUIT (or SIGHUP for that matter, but I'm assuming I can just ignore that one).
It comes up multiple times, here is one example:
switch (sig) {
     case SIGHUP:
     case SIGINT:
     case SIGTERM:
     case SIGQUIT: {
         /*
         // Bunch of code here removed
         */
         exit(0);
         break;
     }
}
Any suggestions?
Windows does only support a small range of signals. SIGQUIT is not supported. mingw just took the definitions from Microsoft.
I'd just check if it was defined before using it:
switch (sig) {
     case SIGINT:
     case SIGTERM:
#ifdef SIGHUP
     case SIGHUP:
#endif
#ifdef SIGQUIT
     case SIGQUIT:
#endif
     {
         /* ... */
     }
}
Or course, you could also check for _WIN32, which is always defined in common windows preprocessors, or __MINGW32__, which is always defined when using a mingw preprocessor.
Don't get confused by the "32" in those names: Both will also be defined when compiling for 64-bit Windows.
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