[systemd-devel] PAMName=login, systemctl stop

Andrei Borzenkov arvidjaar at gmail.com
Mon Jul 3 12:21:51 UTC 2023


On 03.07.2023 14:17, Lennart Poettering wrote:
> On Mo, 03.07.23 10:58, Valentijn Sessink (valentijn at sessink.nl) wrote:
> 
>> Now my remaining question is probably so very basic, that you sort of missed
>> it: my "session" is started from a script and so I'm probably able to stop
>> all services in the session from within this script - if I knew how to find
>> "it": "it" being "the thing to stop", i.e. "my own session" or something
>> like that. I.e. the script should kill itself and all its children.
> 
> logind's session ID you'll find in the $XDG_SESSION_ID env var.
> 
> you can use this to kill your own session:
> 
>      loginctl kill-session $XDG_SESSION_ID
> 

It is not defined here on Ubuntu 22.04 with GNOME 42 that is using 
systemd for session management. It *is* defined in GDM session worker, 
but as actual session processes are not children of it (they are started 
by systemd) this variable is not inherited.

> if you want to know which systemd unit your process belongs to use:
> 
>      ps --pid $$ -o unit=
> 
> Lennart
> 
> --
> Lennart Poettering, Berlin



More information about the systemd-devel mailing list