chiark / gitweb /
core: don't wait for non-control/non-main processes when killing processes on the...
[elogind.git] / src / core / unit.c
index 6427f9137af3085944ddbcec69fc499d22b4e8af..63576a4b700b6479bfd6bd200fc84fdec8929f8a 100644 (file)
@@ -50,6 +50,7 @@
 #include "bus-errors.h"
 #include "dbus.h"
 #include "execute.h"
+#include "virt.h"
 
 const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
         [UNIT_SERVICE] = &service_vtable,
@@ -2921,7 +2922,7 @@ int unit_kill_context(
                 pid_t control_pid,
                 bool main_pid_alien) {
 
-        int sig, wait_for_exit = 0, r;
+        int sig, wait_for_exit = false, r;
 
         assert(u);
         assert(c);
@@ -2940,7 +2941,8 @@ int unit_kill_context(
 
                         log_warning_unit(u->id, "Failed to kill main process " PID_FMT " (%s): %s", main_pid, strna(comm), strerror(-r));
                 } else {
-                        wait_for_exit = !main_pid_alien;
+                        if (!main_pid_alien)
+                                wait_for_exit = true;
 
                         if (c->send_sighup)
                                 kill(main_pid, SIGHUP);
@@ -2976,7 +2978,18 @@ int unit_kill_context(
                         if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
                                 log_warning_unit(u->id, "Failed to kill control group: %s", strerror(-r));
                 } else if (r > 0) {
-                        wait_for_exit = true;
+
+                        /* FIXME: Now, we don't actually wait for any
+                         * of the processes that are neither control
+                         * nor main process. We should wait for them
+                         * of course, but that's hard since the cgroup
+                         * notification logic is so unreliable. It is
+                         * not available at all in containers, and on
+                         * the host it gets confused by
+                         * subgroups. Hence, for now, let's not wait
+                         * for these processes -- but when the kernel
+                         * gets fixed we really should correct
+                         * that. */
 
                         if (c->send_sighup) {
                                 set_free(pid_set);