diff options
Diffstat (limited to 'include/signals.h')
-rw-r--r-- | include/signals.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/signals.h b/include/signals.h new file mode 100644 index 000000000..70fdead42 --- /dev/null +++ b/include/signals.h @@ -0,0 +1,49 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * + */ + +#ifndef SIGNAL_H +#define SIGNAL_H + +#include <signal.h> + +#include "sockets.h" + +/** Represents a signal handler + */ +class Signal : public Pipe +{ + static std::vector<Signal *> SignalHandlers; + static void SignalHandler(int signal); + + struct sigaction action, old; + public: + int signal; + + /** Constructor + * @param s The signal to listen for + */ + Signal(int s); + ~Signal(); + + /** + * Called when the signal is received. + * Note this is not *immediatly* called when the signal is received, + * but it is saved and called at a later time when we are not doing something + * important. This is always called on the main thread, even on systems that + * spawn threads for signals, like Windows. + */ + virtual void OnNotify() = 0; +}; + +#endif + |