diff options
author | Benoit Foucher <benoit@zeroc.com> | 2004-02-10 23:18:16 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2004-02-10 23:18:16 +0000 |
commit | 61e07f2c8b2110b405e47c8bdc94095e0d754042 (patch) | |
tree | 14a31ba3bfc89b806c81f92f388276f467b46e62 /cpp/src/IceUtil/CtrlCHandler.cpp | |
parent | Fixed Win32 build (_win9x -> win9x()) (diff) | |
download | ice-61e07f2c8b2110b405e47c8bdc94095e0d754042.tar.bz2 ice-61e07f2c8b2110b405e47c8bdc94095e0d754042.tar.xz ice-61e07f2c8b2110b405e47c8bdc94095e0d754042.zip |
MacOS X port.
Diffstat (limited to 'cpp/src/IceUtil/CtrlCHandler.cpp')
-rw-r--r-- | cpp/src/IceUtil/CtrlCHandler.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp index c54efff40b1..887483df5dc 100644 --- a/cpp/src/IceUtil/CtrlCHandler.cpp +++ b/cpp/src/IceUtil/CtrlCHandler.cpp @@ -125,13 +125,22 @@ sigwaitThread(void*) sigaddset(&ctrlCLikeSignals, SIGHUP); sigaddset(&ctrlCLikeSignals, SIGINT); sigaddset(&ctrlCLikeSignals, SIGTERM); - + + // // Run until I'm cancelled (in sigwait()) // for(;;) { int signal = 0; int rc = sigwait(&ctrlCLikeSignals, &signal); +#if defined(__APPLE__) + // + // WORKAROUND: sigwait is not a cancelation point on MacOS X. To cancel this thread, the + // destructor cancels the thread and send a signal to the thread to unblock sigwait, then + // we explicitly test for cancellation. + // + pthread_testcancel(); +#endif // // Some sigwait() implementations incorrectly return EINTR // when interrupted by an unblocked caught signal @@ -203,11 +212,20 @@ CtrlCHandler::~CtrlCHandler() { int rc = pthread_cancel(_tid); assert(rc == 0); +#if defined(__APPLE__) + // + // WORKAROUND: sigwait isn't a cancellation point on MacOS X, see + // comment in sigwaitThread + // + rc = pthread_kill(_tid, SIGTERM); + assert(rc == 0); +#endif void* status = 0; rc = pthread_join(_tid, &status); assert(rc == 0); +#if !defined(__APPLE__) assert(status == PTHREAD_CANCELED); - +#endif { StaticMutex::Lock lock(globalMutex); _handler = 0; |