]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: always abandon session scopes before killing them 3762/head
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Jul 2016 11:42:36 +0000 (13:42 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Jul 2016 12:35:15 +0000 (14:35 +0200)
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.

src/login/logind-session.c

index 0b917c23e1ee0a4fc1c0841f896c3fc4b6976c38..b6da237397491f1646115aa7dd34b3080a7836c6 100644 (file)
@@ -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;
 }