From 6d42e462856a89c172ec240d392baa1a6c7c1022 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 28 Aug 2024 16:53:25 +0100 Subject: [PATCH] Upgrade the signal handling. --- DMRGateway.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/DMRGateway.cpp b/DMRGateway.cpp index ff86107..dcfee28 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -101,21 +101,27 @@ int main(int argc, char** argv) do { m_signal = 0; - m_killed = false; // restart, don't exit, if looping from SIGHUP (1) + m_killed = false; CDMRGateway* host = new CDMRGateway(std::string(iniFile)); ret = host->run(); delete host; - if (m_signal == 2) - ::LogInfo("DMRGateway-%s exited on receipt of SIGINT", VERSION); - - if (m_signal == 15) - ::LogInfo("DMRGateway-%s exited on receipt of SIGTERM", VERSION); - - if (m_signal == 1) - ::LogInfo("DMRGateway-%s restarted on receipt of SIGHUP", VERSION); + switch (m_signal) { + case 2: + ::LogInfo("DMRGateway-%s exited on receipt of SIGINT", VERSION); + break; + case 15: + ::LogInfo("MDMRGateway-%s exited on receipt of SIGTERM", VERSION); + break; + case 1: + ::LogInfo("DMRGateway-%s is restarting on receipt of SIGHUP", VERSION); + break; + default: + ::LogInfo("DMRGateway-%s exited on receipt of an unknown signal", VERSION); + break; + } } while (m_signal == 1); ::LogFinalise();