summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/doc-txt/ChangeLog3
-rw-r--r--src/src/exim.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 236ccae8b..459ffe11a 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -165,6 +165,9 @@ JH/30 The (EXPERIMENTAL_DMARC) variable $dmarc_ar_header is withdrawn, being
JH/31 Bug 2257: Fix pipe transport to not use a socket-only syscall.
+HS/03 Set a handler for SIGTERM and call exit(3) if running as PID 1. This
+ allows proper process termination in container environments.
+
Exim version 4.90
-----------------
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. */