From 6df1187bac1e1fb8becace5bdd3997330561b677 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 4 May 2016 06:35:20 +0100 Subject: [PATCH] Handle restarts with SIGHUP. --- MMDVMHost.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index d320a42..20bebfd 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -74,20 +74,26 @@ int main(int argc, char** argv) ::signal(SIGHUP, sigHandler); #endif - CMMDVMHost* host = new CMMDVMHost(std::string(iniFile)); - int ret2 = host->run(); + int ret = 0; - delete host; + do { + m_signal = 0; - if (m_signal == 15) - ::LogInfo("Caught SIGTERM. Exiting"); + CMMDVMHost* host = new CMMDVMHost(std::string(iniFile)); + ret = host->run(); - if (m_signal == 1) - ::LogInfo("Caught SIGHUP. Exiting"); + delete host; + + if (m_signal == 15) + ::LogInfo("Caught SIGTERM, exiting"); + + if (m_signal == 1) + ::LogInfo("Caught SIGHUP, restarting"); + } while (m_signal == 1); ::LogFinalise(); - return ret2; + return ret; } CMMDVMHost::CMMDVMHost(const std::string& confFile) :