Application: Perform hard-shutdown after 3 Ctrl+C's

This commit is contained in:
Lion Kortlepel authored and Lion committed 2021-09-11 11:38:06 +03:00
1 parent ffac000cd2
commit b1664bb184
2 files changed
+10 -4

No files matched your search

+9 -2
View File
@@ -22,10 +22,17 @@ void Application::RegisterShutdownHandler(const TShutdownHandler& Handler) {
}
}
static bool AlreadyShuttingDown = false;
void Application::GracefullyShutdown() {
static bool AlreadyShuttingDown = false;
static uint8_t ShutdownAttempts = 0;
if (AlreadyShuttingDown) {
info("already shutting down");
++ShutdownAttempts;
// hard shutdown at 2 additional tries
if (ShutdownAttempts == 2) {
info("hard shutdown forced by multiple shutdown requests");
exit(0);
}
info("already shutting down!");
return;
} else {
AlreadyShuttingDown = true;