systemd scope leak when program fork quickly enough
Affected version
-
gnome-shell-46~rc-1.fc40.x86_64
on Fedora 40 withsystemd-255.4-1.fc40.x86_64
, running on Wayland with all extension disabled.
Bug summary
If the program specified in Exec=
in desktop fork off child quickly enough, then the child process will be left in org.gnome.Shell@wayland.service
's cgroup instead of being correctly moved to app-gnome-<whatever>.scope
.
Steps to reproduce
Creat a script:
#!/bin/bash
(sleep +inf) | (sleep +inf)
And a corresponding desktop file and install it
[Desktop Entry]
Type=Application
Name=Test
Exec=/path/to/script.sh
NoDisplay=false
StartupNotify=false
And start the installed desktop entry
What happened
The two sleep +inf
process being left in /user.slice/user-1000.slice/user@1000.service/session.slice/org.gnome.Shell@wayland.service
What did you expect to happen
All process of this script should be moved to its scope.
Relevant logs, screenshots, screencasts etc.
Changing the script to:
#!/bin/bash
sleep 1
(sleep +inf) | (sleep +inf)
will give enought time for gnome to move process across cgroup.
Maybe looping over all children process when moving OR do a fork-move-exec trick to start target program in correct cgroup OR just use some DBUS api to ask systemd to start everything on behalf of GNOME?