From: Lennart Poettering Date: Fri, 23 Jun 2017 02:20:09 +0000 (+0200) Subject: nspawn: make sure to send SIGTERM/SIGHUP to the main nspawn process if stubinit recei... X-Git-Tag: v234~107 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a462478539bd3c01c56c2f13413ea4b9ed6afbde;p=thirdparty%2Fsystemd.git nspawn: make sure to send SIGTERM/SIGHUP to the main nspawn process if stubinit receives SIGRTMIN+3 (#6167) 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 --- diff --git a/src/nspawn/nspawn-stub-pid1.c b/src/nspawn/nspawn-stub-pid1.c index 99e52974dcc..0c48434db8e 100644 --- a/src/nspawn/nspawn-stub-pid1.c +++ b/src/nspawn/nspawn-stub-pid1.c @@ -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; }