* Added better handling of SIGBUS, including the error type and fault address in the dump.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1247 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2011-07-20 09:57:29 +00:00
parent f5d4924b22
commit fa8ef65cd7
3 changed files with 74 additions and 1 deletions
+16
View File
@@ -36,7 +36,9 @@
#include "config.h"
#include <signal.h>
#include <stdexcept>
#include "rak/error_number.h"
#include "signal_handler.h"
SignalHandler::Slot SignalHandler::m_handlers[HIGHEST_SIGNAL];
@@ -71,6 +73,20 @@ SignalHandler::set_handler(unsigned int signum, Slot slot) {
m_handlers[signum] = slot;
}
void
SignalHandler::set_sigaction_handler(unsigned int signum, handler_slot slot) {
if (signum > HIGHEST_SIGNAL)
throw std::logic_error("SignalHandler::set_handler(...) received invalid signal value.");
struct sigaction sa;
sa.sa_sigaction = slot;
sa.sa_mask = 0;
sa.sa_flags = SA_SIGINFO;
if (sigaction(signum, &sa, NULL) == -1)
throw std::logic_error("Could not set sigaction: " + std::string(rak::error_number::current().c_str()));
}
void
SignalHandler::caught(int signum) {
if ((unsigned)signum > HIGHEST_SIGNAL)