Skip to content

Commit

Permalink
Fix the restart processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Aug 28, 2024
1 parent cf96a26 commit aa03a96
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,";
Expand All @@ -96,40 +91,40 @@ 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();

delete host;

switch (m_signal) {
case 0:
break;
case 2:
::LogInfo("MMDVMHost-%s exited on receipt of SIGINT", VERSION);
break;
case 15:
::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();

Expand Down

0 comments on commit aa03a96

Please sign in to comment.