Skip to content

Commit e10454c

Browse files
committed
Fix the signal handling.
1 parent f75ad66 commit e10454c

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

MMDVMHost.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015-2021 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2015-2021,2023 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -75,7 +75,7 @@ static void sigHandler2(int signum)
7575
const char* HEADER1 = "This software is for use on amateur radio networks only,";
7676
const char* HEADER2 = "it is to be used for educational purposes only. Its use on";
7777
const char* HEADER3 = "commercial networks is strictly prohibited.";
78-
const char* HEADER4 = "Copyright(C) 2015-2021 by Jonathan Naylor, G4KLX and others";
78+
const char* HEADER4 = "Copyright(C) 2015-2023 by Jonathan Naylor, G4KLX and others";
7979

8080
int main(int argc, char** argv)
8181
{
@@ -112,15 +112,24 @@ int main(int argc, char** argv)
112112

113113
delete host;
114114

115-
if (m_signal == 2)
116-
::LogInfo("MMDVMHost-%s exited on receipt of SIGINT", VERSION);
117-
118-
if (m_signal == 15)
119-
::LogInfo("MMDVMHost-%s exited on receipt of SIGTERM", VERSION);
120-
121-
if (m_signal == 1)
122-
::LogInfo("MMDVMHost-%s is restarting on receipt of SIGHUP", VERSION);
123-
} while (m_signal == 1);
115+
switch (m_signal) {
116+
case 2:
117+
::LogInfo("MMDVMHost-%s exited on receipt of SIGINT", VERSION);
118+
break;
119+
case 15:
120+
::LogInfo("MMDVMHost-%s exited on receipt of SIGTERM", VERSION);
121+
break;
122+
case 1:
123+
::LogInfo("MMDVMHost-%s exited on receipt of SIGHUP", VERSION);
124+
break;
125+
case 10:
126+
::LogInfo("MMDVMHost-%s is restarting on receipt of SIGUSR1", VERSION);
127+
break;
128+
default:
129+
::LogInfo("MMDVMHost-%s exited on receipt of an unknown signal", VERSION);
130+
break;
131+
}
132+
} while (m_signal == 10);
124133

125134
::LogFinalise();
126135

0 commit comments

Comments
 (0)