mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 13:12:32 +00:00
* Tweaked the signals.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1186 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+10
-10
@@ -43,8 +43,8 @@ SignalHandler::Slot SignalHandler::m_handlers[HIGHEST_SIGNAL];
|
||||
|
||||
void
|
||||
SignalHandler::set_default(unsigned int signum) {
|
||||
if (signum >= HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::clear(...) received invalid signal value");
|
||||
if (signum > HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::set_default(...) received invalid signal value.");
|
||||
|
||||
signal(signum, SIG_DFL);
|
||||
m_handlers[signum].disconnect();
|
||||
@@ -52,8 +52,8 @@ SignalHandler::set_default(unsigned int signum) {
|
||||
|
||||
void
|
||||
SignalHandler::set_ignore(unsigned int signum) {
|
||||
if (signum >= HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::clear(...) received invalid signal value");
|
||||
if (signum > HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::set_ignore(...) received invalid signal value.");
|
||||
|
||||
signal(signum, SIG_IGN);
|
||||
m_handlers[signum].disconnect();
|
||||
@@ -61,11 +61,11 @@ SignalHandler::set_ignore(unsigned int signum) {
|
||||
|
||||
void
|
||||
SignalHandler::set_handler(unsigned int signum, Slot slot) {
|
||||
if (signum >= HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::handle(...) received invalid signal value");
|
||||
if (signum > HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::set_handler(...) received invalid signal value.");
|
||||
|
||||
if (slot.empty())
|
||||
throw std::logic_error("SignalHandler::handle(...) received an empty slot");
|
||||
throw std::logic_error("SignalHandler::set_handler(...) received an empty slot.");
|
||||
|
||||
signal(signum, &SignalHandler::caught);
|
||||
m_handlers[signum] = slot;
|
||||
@@ -73,11 +73,11 @@ SignalHandler::set_handler(unsigned int signum, Slot slot) {
|
||||
|
||||
void
|
||||
SignalHandler::caught(int signum) {
|
||||
if ((unsigned)signum >= HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::caught(...) received invalid signal from the kernel, bork bork bork");
|
||||
if ((unsigned)signum > HIGHEST_SIGNAL)
|
||||
throw std::logic_error("SignalHandler::caught(...) received invalid signal from the kernel, bork bork bork.");
|
||||
|
||||
if (m_handlers[signum].empty())
|
||||
throw std::logic_error("SignalHandler::caught(...) received a signal we don't have a handler for");
|
||||
throw std::logic_error("SignalHandler::caught(...) received a signal we don't have a handler for.");
|
||||
|
||||
m_handlers[signum]();
|
||||
}
|
||||
|
||||
@@ -44,8 +44,13 @@ class SignalHandler {
|
||||
public:
|
||||
typedef sigc::slot0<void> Slot;
|
||||
|
||||
static const unsigned int HIGHEST_SIGNAL = SIGUSR2;
|
||||
|
||||
#ifdef SIGRTMAX
|
||||
static const unsigned int HIGHEST_SIGNAL = SIGRTMAX;
|
||||
#else
|
||||
// Let's be on the safe side.
|
||||
static const unsigned int HIGHEST_SIGNAL = 64;
|
||||
#endif
|
||||
|
||||
static void set_default(unsigned int signum);
|
||||
static void set_ignore(unsigned int signum);
|
||||
static void set_handler(unsigned int signum, Slot slot);
|
||||
|
||||
Reference in New Issue
Block a user