libdap++ Updated for version 3.8.2
|
#include <SignalHandler.h>
Public Member Functions | |
EventHandler * | register_handler (int signum, EventHandler *eh, bool override=false) |
EventHandler * | remove_handler (int signum) |
virtual | ~SignalHandler () |
Static Public Member Functions | |
static SignalHandler * | instance () |
Friends | |
class | HTTPCacheTest |
class | SignalHandlerTest |
Singleton to handle signals. This class adapts the C-style function call interface to one suited for C++. This class records a signal's old action/handler when it installs new handler. When a signal is caught, the new handler (registered with this class) is run and then the old action/handler is performed. This ensures that when libdap++ is embedded in code which has a handler for a signal such as SIGINT which does something other than the default, that thing, whatever it may be, gets done.
This class treats signals it registers (using the EventHandler abstract class) differently than ones registered using the signal()
or sigaction()
system interfaces. If the register_handler() method is called and an instance of EventHandler is already bound to signum, then the old EventHandler is returned. However, if there's an existing handler that was set up with sigaction()
, ..., it won't be returned. Instead it will either be run after the newly registered EventHandler or ignored, depending on register_handler()'s override parameter. This feature may be used only for POSIX.1 signals which cause process termination. They are: SIGHUP, SIGINT, SIGKILL, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1, and SIGUSR2.
Definition at line 66 of file SignalHandler.h.
virtual libdap::SignalHandler::~SignalHandler | ( | ) | [inline, virtual] |
Definition at line 107 of file SignalHandler.h.
SignalHandler * libdap::SignalHandler::instance | ( | ) | [static] |
Get a pointer to the single instance of SignalHandler.
Definition at line 129 of file SignalHandler.cc.
EventHandler * libdap::SignalHandler::register_handler | ( | int | signum, |
EventHandler * | eh, | ||
bool | override = false |
||
) |
Register an event handler. By default run any previously registered action/handler such as those installed using sigaction()
. For signals such as SIGALRM (the alarm signal) this may not be what you want; see the override parameter. See also the class description.
signum | Bind the event handler to this signal number. Limited to those signals that, according to POSIX.1, cause process termination. |
eh | A pointer to the EventHandler for signum . |
override | If true , do not run the default handler/action. Instead run eh and then treat the signal as if the original action was SIG_IGN. Default is false. |
Definition at line 149 of file SignalHandler.cc.
References libdap::long_to_string().
Referenced by libdap::DODSFilter::establish_timeout().
EventHandler * libdap::SignalHandler::remove_handler | ( | int | signum | ) |
Remove the event hander.
signum | The signal number of the handler to remove. |
Definition at line 218 of file SignalHandler.cc.
friend class HTTPCacheTest [friend] |
Definition at line 101 of file SignalHandler.h.
friend class SignalHandlerTest [friend] |
Definition at line 100 of file SignalHandler.h.