New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logout leaves running user processes #2975

Closed
thx1111 opened this Issue Apr 6, 2016 · 3 comments

Comments

3 participants
@thx1111

thx1111 commented Apr 6, 2016

Submission type

  • [ X] Bug report
  • Request for enhancement (RFE)

NOTE: Do not submit anything other than bug reports or RFEs via the issue tracker!

systemd version the issue has been seen with

… systemd 229-3

NOTE: Do not submit bug reports about anything but the two most recently released systemd versions upstream!

Used distribution

… Arch Linux

In case of bug report: Expected behaviour you didn't see

… logout terminating running user processes

In case of bug report: Unexpected behaviour you saw

… logout leaves running user processes

In case of bug report: Steps to reproduce the problem

  1. logout
  2. login

After, for instance, running and exiting from KDE, there is:

$ ps lU 1000
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 1000 12915 1 20 0 33960 4428 ep_pol Ss ? 0:00 /usr/lib/systemd/systemd --user
5 1000 12921 12915 20 0 105628 2080 - S ? 0:00 (sd-pam)
4 1000 12926 12908 20 0 16696 4536 wait Ss tty1 0:00 -bash
0 1000 12966 12915 20 0 33052 3908 ep_pol Ss ? 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activat
ion
0 1000 13050 12915 20 0 479028 13228 poll_s Sl ? 0:00 /usr/lib/telepathy/mission-control-5
0 1000 13060 12915 20 0 748068 35624 poll_s Sl ? 0:00 /usr/lib/gnome-online-accounts/goa-daemon
0 1000 13067 12915 20 0 270808 5348 poll_s Ssl ? 0:00 /usr/lib/gvfs/gvfsd
0 1000 13072 12915 20 0 404444 7340 futex_ Sl ? 0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
0 1000 13080 12915 20 0 280964 6524 poll_s Sl ? 0:00 /usr/lib/gnome-online-accounts/goa-identity-service
0 1000 13097 12915 20 0 176596 4904 poll_s Sl ? 0:00 /usr/lib/dconf/dconf-service
0 1000 13137 12915 9 -11 448752 12320 poll_s S<sl ? 9:12 /usr/bin/pulseaudio --daemonize=no
0 1000 13147 13137 20 0 81868 3328 poll_s S ? 0:00 /usr/lib/pulse/gconf-helper
0 1000 13150 12915 20 0 60676 5108 poll_s S ? 0:00 /usr/lib/GConf/gconfd-2
0 1000 13688 12915 20 0 339880 7536 poll_s Ssl ? 0:00 /usr/lib/at-spi2-core/at-spi-bus-launcher
0 1000 13715 13688 20 0 32576 3136 ep_pol S ? 0:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofo
rk --print-address 3
1 1000 20461 1 20 0 165076 824 poll_s Ss ? 0:01 gpg-agent --homedir /home/james/.gnupg --use-standard-socket --daemon
0 1000 21518 12915 20 0 304952 7728 poll_s Ssl ? 0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
0 1000 27429 12915 20 0 187452 5344 poll_s Ssl ? 0:00 /usr/lib/gvfs/gvfsd-metadata
0 1000 30567 12926 20 0 32320 3128 - R+ tty1 0:00 ps lU 1000

Next, with no other sessions, run "exit" or "logout" from the virtual terminal. Then log in again, and run:

$ ps lU 1000
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 1000 12915 1 20 0 34048 4472 ep_pol Ss ? 0:00 /usr/lib/systemd/systemd --user
5 1000 12921 12915 20 0 105628 2080 - S ? 0:00 (sd-pam)
0 1000 12966 12915 20 0 33052 3908 ep_pol Ss ? 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activat
ion
0 1000 13050 12915 20 0 479028 13228 poll_s Sl ? 0:00 /usr/lib/telepathy/mission-control-5
0 1000 13060 12915 20 0 748068 35624 poll_s Sl ? 0:00 /usr/lib/gnome-online-accounts/goa-daemon
0 1000 13067 12915 20 0 270808 5348 poll_s Ssl ? 0:00 /usr/lib/gvfs/gvfsd
0 1000 13072 12915 20 0 404444 7340 futex_ Sl ? 0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
0 1000 13080 12915 20 0 280964 6524 poll_s Sl ? 0:00 /usr/lib/gnome-online-accounts/goa-identity-service
0 1000 13097 12915 20 0 176596 4904 poll_s Sl ? 0:00 /usr/lib/dconf/dconf-service
0 1000 13150 12915 20 0 60676 5108 poll_s S ? 0:00 /usr/lib/GConf/gconfd-2
0 1000 13688 12915 20 0 339880 7536 poll_s Ssl ? 0:00 /usr/lib/at-spi2-core/at-spi-bus-launcher
0 1000 13715 13688 20 0 32576 3136 ep_pol S ? 0:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofo
rk --print-address 3
1 1000 20461 1 20 0 165076 824 poll_s Ss ? 0:01 gpg-agent --homedir /home/james/.gnupg --use-standard-socket --daemon
0 1000 21518 12915 20 0 304952 7728 poll_s Ssl ? 0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
0 1000 27429 12915 20 0 187452 5344 poll_s Ssl ? 0:00 /usr/lib/gvfs/gvfsd-metadata
4 1000 30581 30575 20 0 16564 4524 wait Ss tty1 0:00 -bash
0 1000 30585 30581 20 0 32320 3148 - R+ tty1 0:00 ps lU 1000

Note that bash, pulseaudio, /usr/lib/pulse/gconf-helper, and ps were terminated, but that all the other processes remain across logout.

Try killing "systemd --user":
$ ps lU 1000
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
1 1000 20461 1 20 0 165076 824 poll_s Ss ? 0:01 gpg-agent --homedir /home/james/.gnupg --use-standard-socket --daemon
4 1000 30581 30575 20 0 16696 4696 wait Ss tty1 0:00 -bash
0 1000 30616 30581 20 0 32320 2956 - R+ tty1 0:00 ps lU 1000

Then log out and log in:
$ ps lU 1000
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
1 1000 20461 1 20 0 165076 824 poll_s Ss ? 0:01 gpg-agent --homedir /home/james/.gnupg --use-standard-socket --daemon
4 1000 30629 30621 20 0 16564 4340 wait Ss tty1 0:00 -bash
0 1000 30633 30629 20 0 32320 3112 - R+ tty1 0:00 ps lU 1000

Note that "gpg-agent" is still running, but now, "systemd --user" has not been re-started. And, for instance, KDE will not run at all. "login" has failed to produce a working user session.

Try killing "gpg-agent", log out, and log in:

$ ps lU 1000
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 1000 30821 1 20 0 33956 4512 ep_pol Ss ? 0:00 /usr/lib/systemd/systemd --user
5 1000 30826 30821 20 0 105628 2116 - S ? 0:00 (sd-pam)
4 1000 30831 30817 20 0 16696 4752 wait Ss tty1 0:00 -bash
0 1000 30838 30831 20 0 32320 2956 - R+ tty1 0:00 ps lU 1000

This appears to be back to "normal".

Some of these "lurking" processes can cause subsequent problems when other programs are run, in particular, when re-running KDE.

Possibly, this is a problem with systemd-logind, but whatever, systemd needs to "clean-up" after user log-out.

@agaida

This comment has been minimized.

Show comment
Hide comment
@agaida

agaida Apr 7, 2016

this is not a bug, it's a feature!
have a look into /etc/systemd/logind.conf

agaida commented Apr 7, 2016

this is not a bug, it's a feature!
have a look into /etc/systemd/logind.conf

@thx1111

This comment has been minimized.

Show comment
Hide comment
@thx1111

thx1111 Apr 7, 2016

Ah! Thanks for that.

KillUserProcesses=
Takes a boolean argument. Configures whether the processes of a user should be killed when the user completely logs out (i.e. after the user's last session ended). Defaults to "no".

KillExcludeUsers=
Processes of users listed in KillExcludeUsers= are excluded from being killed. KillExcludeUsers= defaults to "root" and takes precedence over KillOnlyUsers=, which defaults to the empty list.

Hmm - well then, I have to say, it seems that "KillUserProcesses=" should default to "yes", since there is a lot of cruft that can accumulate, and there is a simple "KillExcludeUsers=" that can be applied to force exclusions when needed. For instance, starting and then exiting from KDE, there are a dozen GNOME and other services left running, which are ''not'' killed on logout. Further, the original "/usr/lib/systemd/systemd --user", when left running, can have strange interactions with KDE, which, then, cannot be cured by a simple log-out and log-in. A naive user would be forced to reboot the machine to restore state.

thx1111 commented Apr 7, 2016

Ah! Thanks for that.

KillUserProcesses=
Takes a boolean argument. Configures whether the processes of a user should be killed when the user completely logs out (i.e. after the user's last session ended). Defaults to "no".

KillExcludeUsers=
Processes of users listed in KillExcludeUsers= are excluded from being killed. KillExcludeUsers= defaults to "root" and takes precedence over KillOnlyUsers=, which defaults to the empty list.

Hmm - well then, I have to say, it seems that "KillUserProcesses=" should default to "yes", since there is a lot of cruft that can accumulate, and there is a simple "KillExcludeUsers=" that can be applied to force exclusions when needed. For instance, starting and then exiting from KDE, there are a dozen GNOME and other services left running, which are ''not'' killed on logout. Further, the original "/usr/lib/systemd/systemd --user", when left running, can have strange interactions with KDE, which, then, cannot be cured by a simple log-out and log-in. A naive user would be forced to reboot the machine to restore state.

@poettering

This comment has been minimized.

Show comment
Hide comment
@poettering

poettering Apr 15, 2016

Member

Well, KillUserProcesses= breaks "tmux" and "screen" which makes this political to turn on by default. But yes, I think we should turn it on by default.

Related is the discussion in #3005 where it currently is being discussed whether we should be more agressive there in the future.

Anyway, closing this one here, let's continue in #3005.

Member

poettering commented Apr 15, 2016

Well, KillUserProcesses= breaks "tmux" and "screen" which makes this political to turn on by default. But yes, I think we should turn it on by default.

Related is the discussion in #3005 where it currently is being discussed whether we should be more agressive there in the future.

Anyway, closing this one here, let's continue in #3005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment