diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-03-19 18:10:51 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-03-19 18:13:32 +0700 |
commit | ee7c0cb8d94710f5e40967e16d17071c89253a6d (patch) | |
tree | b976fcdb02ba6b00a5a7a0d24804eff5b1b7f212 | |
parent | c5044cfd80666fc420e7019716613e5c3ab89bb8 (diff) |
hlr.c: properly terminate the process on SIGTERM
As per the systemd.kill manual, when a service is going to be
stopped by systemd, the process will first be terminated via
SIGTERM. If then, after a delay, processes still remain, the
the termination request is repeated with the SIGKILL.
It was observed that osmo-hlr immediately terminates on SIGTERM,
leaving the SQLite database open. As a result, several temporary
files (such as hlr.db-shm, hlr.db-wal) remain, allowing the
further recovery:
DDB ERROR <0001> db.c:86 (283) recovered 10 frames from WAL file
Let's properly handle SIGTERM in the same way as we handle SIGINT.
Change-Id: I1a4a48b95bbaed74ff5a03fb5797a44bdb1fcd3a
-rw-r--r-- | src/hlr.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -612,8 +612,9 @@ static void handle_options(int argc, char **argv) static void signal_hdlr(int signal) { switch (signal) { + case SIGTERM: case SIGINT: - LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); + LOGP(DMAIN, LOGL_NOTICE, "Terminating due to signal=%d\n", signal); quit++; break; case SIGUSR1: @@ -709,6 +710,7 @@ int main(int argc, char **argv) osmo_init_ignore_signals(); signal(SIGINT, &signal_hdlr); + signal(SIGTERM, &signal_hdlr); signal(SIGUSR1, &signal_hdlr); if (cmdline_opts.daemonize) { |