Description of problem:
I a simple script which starts 3 daemons. Each commands immediately becomes a daemon and detaches (so PPID of each is "1"):
which I start via systemd. Starting works fine
systemctl start myservice
and see all 3 daemons are running
however, "systemctl status myservice" only shows PID of the shell above.
Also "systemctl stop myservice" does not do anything at all
Version-Release number of selected component (if applicable):
deamons started from a custom script are not tracked via cgroup
"systemctl status" should also display PIDs of the detached daemons
"systemctl stop" should send SIGKILL to all processes started from my script
right. I know the answer.
It happens because I start the daemons via:
su <service_user> -c command1
su <service_user> -c command2
su <service_user> -c command3
Once I introduced "User=service_user" in my unit file and got rid of the "su", it all started working as I expected.
So it looks like there is a way for a process to escape from a cgroup it was started in, right?
su opens (via pam_systemd.so) a new scope under the user's slice; every process started by su will run in that scope. So it works as expected.