From: Lennart Poettering Date: Wed, 20 Jul 2016 11:42:36 +0000 (+0200) Subject: logind: always abandon session scopes before killing them X-Git-Tag: v231~28^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3762%2Fhead;p=thirdparty%2Fsystemd.git logind: always abandon session scopes before killing them This way systemd is informed that we consider everything inside the scope as "left-over", and systemd can log about killing it. With this change systemd will log about all processes killed due to the session clean-up on KillUserProcesses=yes. --- diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 0b917c23e1e..b6da2373974 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -610,6 +610,14 @@ static int session_stop_scope(Session *s, bool force) { if (!s->scope) return 0; + /* Let's always abandon the scope first. This tells systemd that we are not interested anymore, and everything + * that is left in in the scope is "left-over". Informing systemd about this has the benefit that it will log + * when killing any processes left after this point. */ + r = manager_abandon_scope(s->manager, s->scope, &error); + if (r < 0) + log_warning_errno(r, "Failed to abandon session scope, ignoring: %s", bus_error_message(&error, r)); + + /* Optionally, let's kill everything that's left now. */ if (force || manager_shall_kill(s->manager, s->user->name)) { char *job = NULL; @@ -619,11 +627,8 @@ static int session_stop_scope(Session *s, bool force) { free(s->scope_job); s->scope_job = job; - } else { - r = manager_abandon_scope(s->manager, s->scope, &error); - if (r < 0) - return log_error_errno(r, "Failed to abandon session scope: %s", bus_error_message(&error, r)); - } + } else + s->scope_job = mfree(s->scope_job); return 0; }