Re: How to stop child cgroup caused by PAMName=

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

 



On Thu, Feb 06, 2025 at 08:25:06 +0000, Dluhosch, Michael wrote:

> PAMName=login
[...]
> ExecStop=/usr/bin/stopFoo.sh
> 
> to the main service which does that:
> 
> #!/bin/bash

Don't use bash for scripts.

> systemctl stop $(systemctl status $(pidof <anyProcessNameInsideTheChildCGroup>) | grep user.*slice | grep -o session.*scope)

I'm using:

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 would be much easier if systemd provided $_SYSTEMD_SESSION variable directly:

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

or made this directly accessibe via some kind of:

KillMode=session

-- 
Tomasz Pala <gotar@xxxxxxxxxxxxx>



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

  Powered by Linux