summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2018-03-22 23:32:53 +0100
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2018-03-22 23:40:12 +0100
commit830832c9aac90729e88bab0d1daa1ec8bb6848f5 (patch)
tree903251c2a28d2cc1dd16bec7b9a83631292281d0 /src
parent87e9d061c94e3fdd721b7b04ccbdba7a061f6ca3 (diff)
Set a TERM handler to terminate properly if running as PID 1
Diffstat (limited to 'src')
-rw-r--r--src/src/exim.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/src/exim.c b/src/src/exim.c
index 4d35b51f3..d740814f9 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -187,7 +187,15 @@ DEBUG(D_process_info) debug_printf("set_process_info: %s", process_info);
va_end(ap);
}
+/***********************************************
+* Handler for SIGTERM *
+***********************************************/
+static void
+term_handler(int sig)
+{
+ exit(1);
+}
/*************************************************
@@ -1678,6 +1686,10 @@ descriptive text. */
set_process_info("initializing");
os_restarting_signal(SIGUSR1, usr1_handler);
+/* If running in a dockerized environment, the TERM signal is only
+delegated to the PID 1 if we request it by setting an signal handler */
+if (getpid() == 1) signal(SIGTERM, term_handler);
+
/* SIGHUP is used to get the daemon to reconfigure. It gets set as appropriate
in the daemon code. For the rest of Exim's uses, we ignore it. */