0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

construct: Adjust signal handling stack indicating proper continuation.

This commit is contained in:
Jason Volk 2018-04-04 15:45:47 -07:00
parent 93316f4692
commit 8632998eca

View file

@ -231,10 +231,11 @@ enable_coredumps()
} }
#endif #endif
static void handle_quit(); static bool handle_quit();
static void handle_interruption(); static bool handle_interruption();
static void handle_termstop(); static bool handle_termstop();
static void handle_hangup(); static bool handle_hangup();
static bool handle(const int &signum);
void void
sigfd_handler(const boost::system::error_code &ec, sigfd_handler(const boost::system::error_code &ec,
@ -257,61 +258,92 @@ noexcept
throw std::runtime_error(ec.message()); throw std::runtime_error(ec.message());
} }
switch(signum) if(!handle(signum))
{ return;
case SIGINT: handle_interruption(); break;
case SIGTSTP: handle_termstop(); break;
case SIGHUP: handle_hangup(); break;
case SIGQUIT: handle_quit(); return;
case SIGTERM: handle_quit(); return;
default: break;
}
sigs.async_wait(sigfd_handler); sigs.async_wait(sigfd_handler);
} }
void bool
handle(const int &signum)
{
switch(signum)
{
case SIGINT: return handle_interruption();
case SIGTSTP: return handle_termstop();
case SIGHUP: return handle_hangup();
case SIGQUIT: return handle_quit();
case SIGTERM: return handle_quit();
default: return true;
}
}
bool
handle_quit() handle_quit()
try try
{ {
console_cancel(); console_cancel();
ircd::quit(); ircd::quit();
return false;
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
ircd::log::error("SIGQUIT handler: %s", e.what()); ircd::log::error
{
"SIGQUIT handler: %s", e.what()
};
return true;
} }
void bool
handle_hangup() handle_hangup()
try try
{ {
console_hangup(); console_hangup();
return true;
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
ircd::log::error("SIGHUP handler: %s", e.what()); ircd::log::error
{
"SIGHUP handler: %s", e.what()
};
return true;
} }
void bool
handle_termstop() handle_termstop()
try try
{ {
console_termstop(); console_termstop();
return true;
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
ircd::log::error("SIGTSTP handler: %s", e.what()); ircd::log::error
{
"SIGTSTP handler: %s", e.what()
};
return true;
} }
void bool
handle_interruption() handle_interruption()
try try
{ {
console_cancel(); console_cancel();
console_spawn(); console_spawn();
return true;
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
ircd::log::error("SIGINT handler: %s", e.what()); ircd::log::error
{
"SIGINT handler: %s", e.what()
};
return true;
} }