workaround for SF# 1959059: Poco::SignalHandler deadlock: the SignalHandler can now be disabled globally by adding a #define POCO_NO_SIGNAL_HANDLER to Poco/Config.h

This commit is contained in:
Guenter Obiltschnig 2008-09-17 19:31:19 +00:00
parent c83f8e2434
commit d3eb9ee376
2 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,7 @@
//
// SignalHandler.h
//
// $Id: //poco/svn/Foundation/include/Poco/SignalHandler.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/SignalHandler.h#2 $
//
// Library: Foundation
// Package: Threading
@ -88,6 +88,9 @@ class Foundation_API SignalHandler
///
/// The best way to deal with a SignalException is to log as much context
/// information as possible, to aid in debugging, and then to exit.
///
/// The SignalHandler can be disabled globally by compiling POCO and client
/// code with the POCO_NO_SIGNAL_HANDLER macro defined.
{
public:
SignalHandler();
@ -129,10 +132,14 @@ private:
};
#ifndef POCO_NO_SIGNAL_HANDLER
#define poco_throw_on_signal \
Poco::SignalHandler _poco_signalHandler; \
int _poco_signal = sigsetjmp(_poco_signalHandler.jumpBuffer(), 1); \
if (_poco_signal) _poco_signalHandler.throwSignalException(_poco_signal);
#else
#define poco_throw_on_signal
#endif
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// SignalHandler.cpp
//
// $Id: //poco/svn/Foundation/src/SignalHandler.cpp#2 $
// $Id: //poco/1.3/Foundation/src/SignalHandler.cpp#3 $
//
// Library: Foundation
// Package: Threading
@ -93,6 +93,7 @@ void SignalHandler::throwSignalException(int sig)
void SignalHandler::install()
{
#ifndef POCO_NO_SIGNAL_HANDLER
struct sigaction sa;
sa.sa_handler = handleSignal;
sa.sa_flags = 0;
@ -101,6 +102,7 @@ void SignalHandler::install()
sigaction(SIGBUS, &sa, 0);
sigaction(SIGSEGV, &sa, 0);
sigaction(SIGSYS, &sa, 0);
#endif
}