Skip to content
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

use loginctl kill-session for logging out #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

macedigital
Copy link

Commit changes logout command to gracefully terminate session using a signal only. This should prevent issues with greeters associated with a given user session becoming broken after logout.

New method successfully tested with SwayWM. More feedback for other window managers is welcome.

See #22.

Commit changes logout command to gracefully terminate session using a signal only. This should prevent issues with greeters associated with a given user session becoming broken after logout.

New method successfully tested with SwayWM. More feedback for other window managers is welcome.

See jluttine#22.
@LRitzdorf
Copy link

LRitzdorf commented Jan 1, 2025

Nice! This is much more elegant than a wrapper script with environment-specific commands.

Quick note: loginctl kill-session supports a --signal= flag to control precisely which signal is sent (i.e. instead of SIGKILL). Do we know if, say, SIGINT might be a better choice? This'll obviously be a factor of how various common DEs/WMs/compositors handle signals, but my feeling is that a "gentler" signal might be preferable.

@jluttine
Copy link
Owner

jluttine commented Jan 2, 2025

If [--signal is] omitted, [it] defaults to SIGTERM.

Source: https://www.freedesktop.org/software/systemd/man/latest/loginctl.html

I tried to read a bit but I couldn't quite understand what's the difference between using kill-session and terminate-session. For me, terminate-session has worked (I'm using SDDM + i3). Also, I couldn't find any information which one is the more "correct" way of logging out.

But if this solves an issue and doesn't cause any new issues, I suppose it's probably ok. In any case, thanks for the PR!

@macedigital
Copy link
Author

Afaik, both commands send SIGTERM by default #36 (comment).

Best explanation of the difference I found is on ServerFault:

Similarly, loginctl terminate-session [...] will explicitly mark the .scope as "abandoned" before trying to stop it, [...].
https://serverfault.com/questions/1103060/what-is-the-functional-difference-between-loginctl-terminate-session-loginctl

My working hypothesis is that terminate-session command somehow pulls the rug under certain combinations of window manager, greeter, session management, etc. whereas kill-session (sending SIGTERM) gives the session the opportunity to handle termination and/or perform cleanup before exiting on its own terms.

Could also indicate a subtle bug in any of the underlying software components 🤷

But if this solves an issue and doesn't cause any new issues, I suppose it's probably ok.
#36 (comment)

Exactly, I would definitely wait for more feedback or "up votes" before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants