diff options
author | Adam <Adam@anope.org> | 2011-08-10 00:28:31 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-08-10 00:28:31 -0400 |
commit | 13bcc4ef14c0c61e8ed578ac9346291ae731b8df (patch) | |
tree | 29f024c498fe0f713183a3e6ddd0e82f22567565 | |
parent | ce92c9b21b99f6a2e2d2a79ce119233699c1a81a (diff) |
Replace the old sigaction for a signal when our Signal destructs
-rw-r--r-- | include/services.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/include/services.h b/include/services.h index addaf6ae8..6e7243c10 100644 --- a/include/services.h +++ b/include/services.h @@ -244,7 +244,7 @@ class Signal static std::vector<Signal *> SignalHandlers; static void SignalHandler(int signal); - struct sigaction action; + struct sigaction action, old; sig_atomic_t called; public: static void Process(); diff --git a/src/main.cpp b/src/main.cpp index f4316d6e0..97ee2a844 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -225,11 +225,14 @@ void Signal::Process() Signal::Signal(int s) : called(false), signal(s) { + memset(&this->old, 0, sizeof(this->old)); + this->action.sa_flags = 0; sigemptyset(&this->action.sa_mask); this->action.sa_handler = SignalHandler; - sigaction(s, &this->action, NULL); + if (sigaction(s, &this->action, &this->old) == -1) + throw CoreException("Unable to install signal " + stringify(s) + ": " + Anope::LastError()); SignalHandlers.push_back(this); } @@ -239,6 +242,8 @@ Signal::~Signal() std::vector<Signal *>::iterator it = std::find(SignalHandlers.begin(), SignalHandlers.end(), this); if (it != SignalHandlers.end()) SignalHandlers.erase(it); + + sigaction(this->signal, &this->old, NULL); } |