-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use systemd as subreaper #96
Conversation
- For now, execute the launcher within the Flatpak sandbox. Breaking out the sandbox via flatpak-spawn is discouraged and breaks Flatpak's security model. It may also require other Flatpak applications to make additional changes in their manifest, which they may not be supportive to do for this practice. Unless necessary or proven to be very problematic, execute within the Flatpak sandbox
- To run games, the only required files to be in the user's home directory is the runtime platform and the reaper executable. The launcher files will remain in their system path that's been configured in build time.
- The directory /usr/share/steam/compatibilitytool.d is an official system path supported by Valve's Steam client to search for community-based tools and to use them as compatibility tools to run games. Instead of copying the umu-launcher directory to ~/.local/share/Steam/compatibilitytool.d we can install it in its system path. That way, there's less to copy/remove and the files there can be managed by the distribution's package manager
- The system path compatibilitytools.d directory will be used instead
- The launcher only needs this directory to write Proton. For now, just limit access to this directory instead of exposing user's entire ~/.local/share
- For now, hide this tool in the Steam client until the umu runtime platform is released. - Related to Open-Wine-Components#4
- Instead of Valve's Reaper for subreaping, a user-transient scoped unit via systemd-run can be used instead when executing games. This is what Flatpak uses to provide resource isolation for flatpak-run commands, and this comes with some advantages such as allowing the management of processes and resource control via systemd and not requiring clients to compile Reaper. Currently, it is not possible to kill the entire process tree for a game if a gamescope window was closed. However, using systemd, if a gamescope was used for the running game and the window was closed, the entire process tree created can be killed by simply stopping it's systemd unit via `systemctl --user stop unitID` and monitored via `systemctl status --user status unitId`.
- The launcher will not copy Reaper anymore
I am fully supportive of using and defaulting to |
I'm actually have different thoughts about this, so I will close this. I think this will only be really useful if users want to apply limits or restrict capabilities to the subprocess and there is currently no use case for that. In comparison, the same effect can be achieved by building reaper into the launcher itself or using pressure-vessel-adverb --subreaper. The former is much simpler, so I plan to just implement that instead and get rid of the reaper stuff. |
Intended to be merged after 0.1 release, this pull request changes the subreaper from Valve's Reaper to systemd to reap spawned processes after a game is launched and exits.
When systemd is used as a subreaper process, a user-scoped transient unit will be created to reliably track/control all of the processes created at launch and to, optionally, manage their system resource usages (which is how Flatpak uses it). Systemd relies on Linux Control Groups (cgroups) to accomplish this, and all processes in the unit will be logically grouped together in a hierachical tree.
For clients, this means reaper does not need to be compiled on the system, eliminating the potential glibc locks when distributing reaper to old distributions, and all spawned subprocesses in that cgroup that fork/detach (e.g., winetricks) can reliably be killed. In addition, the entire process tree created after launching a game can be easily managed and monitored by the user via systemctl.
For example:
This unit can be closed via
systemctl stop --user run-rc87623c08463475fbda10b1cc575cb38.scope
from the CLI or getting the invocation ID fromsystemctl list-units --user -o json
by its UMU_ID then stopping the unit by its name.Subreaping via systemd will not apply to the umu Flatpak as Flatpaks apply the
--die-with-parent
option by default, and already uses transient scoped units internally to accomplish the same effect.