Overview
Features
Download
Documentation
Community
Add-Ons & Services

Poco::SignalHandler with SIGINT, SIGQUIT and SIGTERM

Please post support and help requests here.

Poco::SignalHandler with SIGINT, SIGQUIT and SIGTERM

Postby ameier » 29 Oct 2009, 09:47

Good day

I was looking for a C++ signal handling solution... and found Poco::SignalHandler which is asynchronously catching the signals SIGILL, SIGBUS, SIGSEGV, SIGSYS and throwing corresponding Poco::SignalExceptions upon issuing poco_throw_on_signal.

I would like to use the Poco::SignalHandler with the signals SIGINT, SIGIQUIT and SIGTERM...
Can I use the SignalHandler for that too? How?
With the static functions it seems not so easy to subclass Poco::SignalHandler.

Best regards,
Andreas
ameier
 
Posts: 1
Joined: 28 Oct 2009, 18:21

Re: Poco::SignalHandler with SIGINT, SIGQUIT and SIGTERM

Postby alex » 10 Nov 2009, 01:07

ameier wrote:I would like to use the Poco::SignalHandler with the signals SIGINT, SIGIQUIT and SIGTERM...
Can I use the SignalHandler for that too? How?

It looks like you won't be able to use it because handleSignal is protected. There may be a reason for that that I'm missing, but if it were not, you'd be able to do this:
Code: Select all
struct sigaction sa;
sa.sa_handler = Poco::SignalHandler::handleSignal;
sa.sa_flags   = 0;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT,  &sa, 0);
sigaction(SIGIQUIT,  &sa, 0);
sigaction(SIGTERM,  &sa, 0);

So, I guess your only hope is to plead with Guenter for the feature of "unprotecting" the SignalHandler::handleSignal. And while you're there, SignalHandler::install() could get an argument (defaulting to something, in order not to break any code) or two (to also be able to supply the exception description string).

BTW, while looking at the code, I stumbled over a small error in the documentation:
Code: Select all
--- C:/Temp/SignalHandler.h-revBASE.svn000.tmp.h   Mon Nov 09 18:02:25 2009
+++ C:/poco-1.3.5/Foundation/include/Poco/SignalHandler.h   Mon Nov 09 17:38:40 2009
@@ -57,7 +57,7 @@
    /// This helper class simplifies the handling of POSIX signals.
    ///
    /// The class provides a signal handler (installed with
-   /// installHandlers()) that translates certain POSIX
+   /// install()) that translates certain POSIX
    /// signals (SIGILL, SIGBUS, SIGSEGV, SIGSYS) into
    /// C++ exceptions.
    ///
alex
 
Posts: 1130
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron