Reputation: 139
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?
Upvotes: 5
Views: 3885
Reputation: 33212
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.
Upvotes: 7