From cc1193ef0caaf5de9d7d1f443a7e90f44f5277a1 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 28 Oct 2011 11:59:51 -0500 Subject: FbTk/SignalHandler.cc: Use HAVE_SIGACTION, with signal() fallback This fixes platforms without sigaction, like Windows. --- src/FbTk/SignalHandler.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/FbTk/SignalHandler.cc b/src/FbTk/SignalHandler.cc index a0a4c4c..5f06210 100644 --- a/src/FbTk/SignalHandler.cc +++ b/src/FbTk/SignalHandler.cc @@ -46,6 +46,7 @@ bool SignalHandler::registerHandler(int signum, SignalEventHandler *eh, if (oldhandler_ret != 0) *oldhandler_ret = s_signal_handler[signum]; +#ifdef HAVE_SIGACTION struct sigaction sa; // set callback sa.sa_handler = SignalHandler::handleSignal; @@ -54,7 +55,12 @@ bool SignalHandler::registerHandler(int signum, SignalEventHandler *eh, if (sigaction(signum, &sa, 0) == -1) return false; - +#else + // Fallback code for Windows and other platforms lacking sigaction. + if (signal(signum, &SignalHandler::handleSignal) == SIG_ERR) { + return false; + } +#endif s_signal_handler[signum] = eh; return true; -- cgit v0.11.2