summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-08-20 20:50:06 +0200
committerHarald Welte <laforge@gnumonks.org>2017-08-20 19:24:10 +0000
commit84b7e3723b8d7bf9bfd5db7ba5532c3d174c2c77 (patch)
tree026399b11b589c2b470a287f29837c7c1931d1d2
parentf0288cacc5b6be1943c25584327c80974639097e (diff)
Treat SIGTERM just like SIGINT in our programs
When somebody kills the process, it's best to handle the signal and to use the opportunity for some cleanup. We always did this in the NITB on SIGINT, but never on SIGTERM. Let's change it. Change-Id: Iea6804325a6575ceab5edfd28dd20249462f143b
-rw-r--r--openbsc/src/gprs/gb_proxy_main.c2
-rw-r--r--openbsc/src/gprs/gtphub_main.c2
-rw-r--r--openbsc/src/gprs/sgsn_main.c2
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_main.c2
-rw-r--r--openbsc/src/osmo-nitb/bsc_hack.c2
5 files changed, 10 insertions, 0 deletions
diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c
index 69a93b6f7..caff27f6f 100644
--- a/openbsc/src/gprs/gb_proxy_main.c
+++ b/openbsc/src/gprs/gb_proxy_main.c
@@ -98,6 +98,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
+ case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(1);
exit(0);
@@ -232,6 +233,7 @@ int main(int argc, char **argv)
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
signal(SIGINT, &signal_handler);
+ signal(SIGTERM, &signal_handler);
signal(SIGABRT, &signal_handler);
signal(SIGUSR1, &signal_handler);
signal(SIGUSR2, &signal_handler);
diff --git a/openbsc/src/gprs/gtphub_main.c b/openbsc/src/gprs/gtphub_main.c
index 73a122c31..2b87d19ef 100644
--- a/openbsc/src/gprs/gtphub_main.c
+++ b/openbsc/src/gprs/gtphub_main.c
@@ -96,6 +96,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
+ case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(1);
exit(0);
@@ -302,6 +303,7 @@ int main(int argc, char **argv)
msgb_talloc_ctx_init(osmo_gtphub_ctx, 0);
signal(SIGINT, &signal_handler);
+ signal(SIGTERM, &signal_handler);
signal(SIGABRT, &signal_handler);
signal(SIGUSR1, &signal_handler);
signal(SIGUSR2, &signal_handler);
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index 04f2825f7..c1da585d4 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -142,6 +142,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
+ case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(1);
exit(0);
@@ -335,6 +336,7 @@ int main(int argc, char **argv)
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
signal(SIGINT, &signal_handler);
+ signal(SIGTERM, &signal_handler);
signal(SIGABRT, &signal_handler);
signal(SIGUSR1, &signal_handler);
signal(SIGUSR2, &signal_handler);
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index ee094d670..90651b95e 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -162,6 +162,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
+ case SIGTERM:
bsc_shutdown_net(bsc_gsmnet);
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(3);
@@ -280,6 +281,7 @@ int main(int argc, char **argv)
}
signal(SIGINT, &signal_handler);
+ signal(SIGTERM, &signal_handler);
signal(SIGABRT, &signal_handler);
signal(SIGUSR1, &signal_handler);
signal(SIGUSR2, &signal_handler);
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index c2fe1c96b..2aeaa8fef 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -202,6 +202,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
+ case SIGTERM:
bsc_shutdown_net(bsc_gsmnet);
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(3);
@@ -376,6 +377,7 @@ int main(int argc, char **argv)
osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
signal(SIGINT, &signal_handler);
+ signal(SIGTERM, &signal_handler);
signal(SIGABRT, &signal_handler);
signal(SIGUSR1, &signal_handler);
signal(SIGUSR2, &signal_handler);