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.
- Note
- Based on "Applying Design Patterns to Simplify Signal Handling", Douglas C. Schmidt, 1998, http://www.cs.wustl.edu/~schmidt/signal-patterns.html.
- See also
- EventHandler
- Author
- James Gallagher jgall.nosp@m.aghe.nosp@m.r@ope.nosp@m.ndap.nosp@m..org
Definition at line 66 of file SignalHandler.h.