]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: make sure to send SIGTERM/SIGHUP to the main nspawn process if stubinit recei...
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Jun 2017 02:20:09 +0000 (04:20 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Jun 2017 02:20:09 +0000 (22:20 -0400)
This code already existed in some form, however commented. Remove the
comments, as this was most likely simply a forgotten commenting for
debugging purposes.

This also extends the logic a bit, by sending SIGHUP right after the
SIGTERM, so that shells will also terminate, when PID 1 gets a
SIGRTMIN+3.

Fixes: #5711
src/nspawn/nspawn-stub-pid1.c

index 99e52974dcc4f3b1e8843659e13e36cf537df92e..0c48434db8e78ad4b9206fa24fba789411d92956 100644 (file)
@@ -188,7 +188,16 @@ int stub_pid1(sd_id128_t uuid) {
                 else
                         assert_not_reached("Got unexpected signal");
 
-                /* (void) kill_and_sigcont(pid, SIGTERM); */
+                r = kill_and_sigcont(pid, SIGTERM);
+
+                /* Let's send a SIGHUP after the SIGTERM, as shells tend to ignore SIGTERM but do react to SIGHUP. We
+                 * do it strictly in this order, so that the SIGTERM is dispatched first, and SIGHUP second for those
+                 * processes which handle both. That's because services tend to bind configuration reload or something
+                 * else to SIGHUP. */
+
+                if (r != -ESRCH)
+                        (void) kill(pid, SIGHUP);
+
                 quit_usec = now(CLOCK_MONOTONIC) + DEFAULT_TIMEOUT_USEC;
         }