mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-29 18:43:56 +00:00
gtk: revamp cgroup/transient scope handling
This changes the way Ghostty assigns itself and subprocesses to cgroups and how resource controls are applied. * Ghostty itself no longer modifies it's own cgroup or moves itself to a transient scope. To modify the main Ghostty process' resource controls ensure that you're launching Ghostty with a systemd unit and use the standard systemd methods for overriding and applying changes to systemd units. * If configured (on by default), the process used to run your command will be moved to a transient systemd scope after it is forked from Ghostty but before the user's command is executed. Resource controls will be applied to the transient scope at this time. Changes to the `linux-cgroup*` configuration entries will not alter existing commands. If changes are made to the `linux-cgroup*` configuration entries commands will need to be relaunched. Resource limits can also be modified after launch outside of Ghostty using systemd tooling. The transient scope name can be shown by running `systemctl --user whoami` in a shell running inside Ghostty. Fixes #2084. Related to #6669
This commit is contained in:
@@ -636,16 +636,8 @@ pub fn init(
|
||||
.working_directory = config.@"working-directory",
|
||||
.resources_dir = global_state.resources_dir.host(),
|
||||
.term = config.term,
|
||||
|
||||
// Get the cgroup if we're on linux and have the decl. I'd love
|
||||
// to change this from a decl to a surface options struct because
|
||||
// then we can do memory management better (don't need to retain
|
||||
// the string around).
|
||||
.linux_cgroup = if (comptime builtin.os.tag == .linux and
|
||||
@hasDecl(apprt.runtime.Surface, "cgroup"))
|
||||
rt_surface.cgroup()
|
||||
else
|
||||
Command.linux_cgroup_default,
|
||||
.rt_pre_exec_info = .init(config),
|
||||
.rt_post_fork_info = .init(config),
|
||||
});
|
||||
errdefer io_exec.deinit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user