diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-07-20 13:42:36 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-07-20 14:35:15 +0200 |
commit | 756ed0e238b7243c2e4616083e838d90de6e33ed (patch) | |
tree | cb431d797c51f4434c83bda04fedee9b7540b0e0 | |
parent | 3862e809d04f4119d294719982a1dce9a0f444d2 (diff) |
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.
-rw-r--r-- | src/login/logind-session.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 0b917c23e1..b6da237397 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; } |