From aa03a969252e2e8d0f814195357094d5ea311983 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 28 Aug 2024 16:32:20 +0100 Subject: [PATCH] Fix the restart processing. --- MMDVMHost.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 937967f0..f29d0ef9 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -60,16 +60,11 @@ static int m_signal = 0; static bool m_reload = false; #if !defined(_WIN32) && !defined(_WIN64) -static void sigHandler1(int signum) +static void sigHandler(int signum) { m_killed = true; m_signal = signum; } - -static void sigHandler2(int signum) -{ - m_reload = true; -} #endif const char* HEADER1 = "This software is for use on amateur radio networks only,"; @@ -96,16 +91,16 @@ int main(int argc, char** argv) } #if !defined(_WIN32) && !defined(_WIN64) - ::signal(SIGINT, sigHandler1); - ::signal(SIGTERM, sigHandler1); - ::signal(SIGHUP, sigHandler1); - ::signal(SIGUSR1, sigHandler2); + ::signal(SIGINT, sigHandler); + ::signal(SIGTERM, sigHandler); + ::signal(SIGHUP, sigHandler); #endif int ret = 0; do { m_signal = 0; + m_killed = false; CMMDVMHost* host = new CMMDVMHost(std::string(iniFile)); ret = host->run(); @@ -113,6 +108,8 @@ int main(int argc, char** argv) delete host; switch (m_signal) { + case 0: + break; case 2: ::LogInfo("MMDVMHost-%s exited on receipt of SIGINT", VERSION); break; @@ -120,16 +117,14 @@ int main(int argc, char** argv) ::LogInfo("MMDVMHost-%s exited on receipt of SIGTERM", VERSION); break; case 1: - ::LogInfo("MMDVMHost-%s exited on receipt of SIGHUP", VERSION); - break; - case 10: - ::LogInfo("MMDVMHost-%s is restarting on receipt of SIGUSR1", VERSION); + ::LogInfo("MMDVMHost-%s is restarting on receipt of SIGHUP", VERSION); + m_reload = true; break; default: ::LogInfo("MMDVMHost-%s exited on receipt of an unknown signal", VERSION); break; } - } while (m_signal == 10); + } while (m_reload || (m_signal == 1)); ::LogFinalise();