84b277
From 2f960b84dad97c50c819f2c11812fe6f302ec2ca Mon Sep 17 00:00:00 2001
84b277
From: Lennart Poettering <lennart@poettering.net>
84b277
Date: Thu, 6 Feb 2014 01:50:41 +0100
84b277
Subject: [PATCH] core: only send SIGHUP when doing first kill, not when doing
84b277
 final sigkill
84b277
84b277
Conflicts:
84b277
	src/core/unit.c
84b277
84b277
(cherry-picked from 97e0691f85da6e7ea131ce80bd61e2d47a737a61)
84b277
84b277
Resolves: #1147524
84b277
---
84b277
 src/core/unit.c | 20 ++++++++++++++++----
84b277
 1 file changed, 16 insertions(+), 4 deletions(-)
84b277
84b277
diff --git a/src/core/unit.c b/src/core/unit.c
84b277
index 855e135..fe1864a 100644
84b277
--- a/src/core/unit.c
84b277
+++ b/src/core/unit.c
84b277
@@ -3113,7 +3113,7 @@ int unit_kill_context(
84b277
                 } else {
84b277
                         wait_for_exit = !main_pid_alien;
84b277
 
84b277
-                        if (c->send_sighup)
84b277
+                        if (c->send_sighup && !sigkill)
84b277
                                 kill(main_pid, SIGHUP);
84b277
                 }
84b277
         }
84b277
@@ -3131,7 +3131,7 @@ int unit_kill_context(
84b277
                 } else {
84b277
                         wait_for_exit = true;
84b277
 
84b277
-                        if (c->send_sighup)
84b277
+                        if (c->send_sighup && !sigkill)
84b277
                                 kill(control_pid, SIGHUP);
84b277
                 }
84b277
         }
84b277
@@ -3149,8 +3149,20 @@ int unit_kill_context(
84b277
                         if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
84b277
                                 log_warning_unit(u->id, "Failed to kill control group: %s", strerror(-r));
84b277
                 } else if (r > 0) {
84b277
-                        wait_for_exit = true;
84b277
-                        if (c->send_sighup) {
84b277
+
84b277
+                        /* FIXME: Now, we don't actually wait for any
84b277
+                         * of the processes that are neither control
84b277
+                         * nor main process. We should wait for them
84b277
+                         * of course, but that's hard since the cgroup
84b277
+                         * notification logic is so unreliable. It is
84b277
+                         * not available at all in containers, and on
84b277
+                         * the host it gets confused by
84b277
+                         * subgroups. Hence, for now, let's not wait
84b277
+                         * for these processes -- but when the kernel
84b277
+                         * gets fixed we really should correct
84b277
+                         * that. */
84b277
+
84b277
+                        if (c->send_sighup && !sigkill) {
84b277
                                 set_free(pid_set);
84b277
 
84b277
                                 pid_set = unit_pid_set(main_pid, control_pid);