Re: PAMName=login, systemctl stop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03.07.2023 14:17, Lennart Poettering wrote:

> 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
>
> if you want to know which systemd unit your process belongs to use:
>
>	ps --pid $$ -o unit=

I was struggling with the same problem a few months ago and came up with (bear up):


ExecStop=/bin/sh -c "loginctl kill-session --signal SIGTERM `systemctl -n1 -o export status \"$MAINPID\" | grep _SYSTEMD_SESSION | cut -f2 -d=`"
ExecStopPost=/bin/sh -c "loginctl terminate-session         `systemctl -n1 -o export status \"$MAINPID\" | grep _SYSTEMD_SESSION | cut -f2 -d=`"


This worked well (I'm not using it though, it was only some test setup),
but I was wondering if systemd couldn't help somehow, e.g. exposing
$_SYSTEMD_SESSION variable directly;

ExecStop=loginctl kill-session --signal SIGTERM $_SYSTEMD_SESSION

doesn't look so scary anymore. Another idea was to ask for new feature:

KillMode=session

which could do exactly this.

-- 
Tomasz Pala <gotar@xxxxxxxxxxxxx>



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux