diff options
author | Alan Jenkins <alan.christopher.jenkins@gmail.com> | 2018-06-01 19:03:21 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-06-04 11:31:11 +0200 |
commit | 8150acb16090e5213eea68679eb5aaba868cb570 (patch) | |
tree | 31c22f1850e947ccd12a8343c16f2dd5596d13e0 | |
parent | 2a13fafd894013e14d0e1febbcb8c56f519e0db7 (diff) | |
download | systemd-8150acb16090e5213eea68679eb5aaba868cb570.tar.gz |
login: log session state "closing" (as well as New/Removed)
Let's show a message at the time of logout i.e. entering the "closing"
state, not just e.g. once the user closes `tmux` and the session can be
removed completely. (At least when KillUserProcesses=no applies. My
thinking was we can spare the log noise if we're killing the processes
anyway).
These are two independent events. I think the logout event is quite
significant in the session lifecycle. It will be easier for a user who
does not know logind details to understand why "Removed session" doesn't
appear at logout time, if we have a specific message we can show at this
time :).
Tested using tmux and KillUserProcesses=no. I can also confirm the extra
message doesn't show when using KillUserProcesses=yes. Maybe it looks a
bit mysterious when you use KillOnlyUsers= / KillExcludeUsers=, but
hopefully not alarmingly so.
I was looking at systemd-logind messages on my system, because I can
reproduce two separate problems with Gnome on Fedora 28 where
sessions are unexpectedly in state "closing". (One where a GUI session
limps along in a degraded state[1], and another where spice-vdagent is left
alive after logout, keeping the session around[2]). It logged when
sessions were created and removed, but it didn't log when the session
entered the "closing" state.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1583240#c1
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1583261
Closes #9096
-rw-r--r-- | src/login/logind-session.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c index a82498c92e..4fb9491bb4 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -671,9 +671,20 @@ static int session_stop_scope(Session *s, bool force) { free(s->scope_job); s->scope_job = job; - } else + } else { s->scope_job = mfree(s->scope_job); + /* With no killing, this session is allowed to persist in "closing" state indefinitely. + * Therefore session stop and session removal may be two distinct events. + * Session stop is quite significant on its own, let's log it. */ + log_struct(s->class == SESSION_BACKGROUND ? LOG_DEBUG : LOG_INFO, + "SESSION_ID=%s", s->id, + "USER_ID=%s", s->user->name, + "LEADER="PID_FMT, s->leader, + LOG_MESSAGE("Session %s logged out. Waiting for processes to exit.", s->id), + NULL); + } + return 0; } |