From d51ba994c97179fe07f5073f6b64661afa7aeaa1 Mon Sep 17 00:00:00 2001 From: g0wfv Date: Thu, 8 Jun 2017 10:17:00 +0100 Subject: [PATCH] Add SIGINT handling and alter termination signal logging --- MMDVMHost.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2fb660f..2867cab 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -95,6 +95,7 @@ int main(int argc, char** argv) } #if !defined(_WIN32) && !defined(_WIN64) + ::signal(SIGINT, sigHandler); ::signal(SIGTERM, sigHandler); ::signal(SIGHUP, sigHandler); #endif @@ -109,11 +110,14 @@ int main(int argc, char** argv) delete host; + if (m_signal == 2) + ::LogInfo("MMDVMHost-%s is exited on receipt of SIGINT", VERSION); + if (m_signal == 15) - ::LogInfo("Caught SIGTERM, exiting"); + ::LogInfo("MMDVMHost-%s is exited on receipt of SIGTERM", VERSION); if (m_signal == 1) - ::LogInfo("Caught SIGHUP, restarting"); + ::LogInfo("MMDVMHost-%s is restarting on receipt of SIGHUP", VERSION); } while (m_signal == 1); ::LogFinalise(); @@ -745,8 +749,6 @@ int CMMDVMHost::run() CThread::sleep(5U); } - LogMessage("MMDVMHost-%s is exiting on receipt of SIGHUP1", VERSION); - setMode(MODE_IDLE); m_modem->close();