X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Funit.c;h=78d7b534b2719c278dd86c85ff70649ba87c4588;hb=486e99a387adec15738c2822c2df5c813955f433;hp=e5ea994e5473a20cf47c355cad13649ad1d77e85;hpb=36be24c8f82141fda995841d177e9e4113e1ef06;p=elogind.git diff --git a/src/core/unit.c b/src/core/unit.c index e5ea994e5..78d7b534b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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); @@ -2938,10 +2939,10 @@ int unit_kill_context( _cleanup_free_ char *comm = NULL; get_process_comm(main_pid, &comm); - log_warning_unit(u->id, "Failed to kill main process %li (%s): %s", - (long) main_pid, strna(comm), strerror(-r)); + 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); @@ -2955,9 +2956,7 @@ int unit_kill_context( _cleanup_free_ char *comm = NULL; get_process_comm(control_pid, &comm); - log_warning_unit(u->id, - "Failed to kill control process %li (%s): %s", - (long) control_pid, strna(comm), strerror(-r)); + log_warning_unit(u->id, "Failed to kill control process " PID_FMT " (%s): %s", control_pid, strna(comm), strerror(-r)); } else { wait_for_exit = true; @@ -2966,7 +2965,7 @@ int unit_kill_context( } } - if (c->kill_mode == KILL_CONTROL_GROUP && u->cgroup_path) { + if ((c->kill_mode == KILL_CONTROL_GROUP || (c->kill_mode == KILL_MIXED && sigkill)) && u->cgroup_path) { _cleanup_set_free_ Set *pid_set = NULL; /* Exclude the main/control pids from being killed via the cgroup */ @@ -2979,7 +2978,17 @@ 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, this is a terrible hack: in + * containers cgroup empty notifications don't + * work. Hence we'll not wait for them to run + * empty for now, since there is no way to + * detect when a service ends with no main PID + * known... */ + + if (detect_container(NULL) <= 0) + wait_for_exit = true; + if (c->send_sighup) { set_free(pid_set);