summaryrefslogtreecommitdiff
path: root/lib/common/Timer.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-09-01 16:58:15 +0000
committerChris Wilson <chris+github@qwirx.com>2007-09-01 16:58:15 +0000
commit86deff6eb3b2308ea88d78b2c4eba1208d9abfb4 (patch)
tree79228f350fd8fed2d817ab51d64203a5518b213b /lib/common/Timer.cpp
parentf43a65d77ecccdc5e49d4dbfdbb498a7e0799afa (diff)
Use sigset() instead of signal() to ensure that SysV systems (like Solaris)
will not clear our signal handler after firing it.
Diffstat (limited to 'lib/common/Timer.cpp')
-rw-r--r--lib/common/Timer.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/common/Timer.cpp b/lib/common/Timer.cpp
index fe565c21..a032f330 100644
--- a/lib/common/Timer.cpp
+++ b/lib/common/Timer.cpp
@@ -39,7 +39,7 @@ void Timers::Init()
InitTimer();
SetTimerHandler(Timers::SignalHandler);
#else
- sighandler_t oldHandler = ::signal(SIGALRM,
+ sighandler_t oldHandler = ::sigset(SIGALRM,
Timers::SignalHandler);
ASSERT(oldHandler == 0);
#endif // WIN32 && !PLATFORM_CYGWIN
@@ -70,7 +70,7 @@ void Timers::Cleanup()
int result = ::setitimer(ITIMER_REAL, &timeout, NULL);
ASSERT(result == 0);
- sighandler_t oldHandler = ::signal(SIGALRM, NULL);
+ sighandler_t oldHandler = ::sigset(SIGALRM, NULL);
ASSERT(oldHandler == Timers::SignalHandler);
#endif // WIN32 && !PLATFORM_CYGWIN
@@ -146,8 +146,11 @@ void Timers::Reschedule()
}
#ifndef WIN32
- if (::signal(SIGALRM, Timers::SignalHandler) != Timers::SignalHandler)
+ void (*oldhandler)(int) = ::sigset(SIGALRM, Timers::SignalHandler);
+ if (oldhandler != Timers::SignalHandler)
{
+ printf("Signal handler was %p, expected %p\n",
+ oldhandler, Timers::SignalHandler);
THROW_EXCEPTION(CommonException, Internal)
}
#endif