Repository navigation
Linux: the engine an app starts outlives the app's systemd unit - #1391
Draft
alexandre-vl wants to merge 1 commit into
Draft
alexandre-vl wants to merge 1 commit into
alexandre-vl wants to merge 1 commit into
Conversation
Under a systemd user manager an app runs in a unit of its own: uwsm starts each app as a service (app-Hyprland-zeron@….service), GNOME and KDE as a scope. The engine the app started stayed in that unit's cgroup, its own session notwithstanding, and a service stops as soon as its main process exits, systemd killing everything left in it: on Hyprland under uwsm, quitting Zeron took its engine down, and every session it ran, which crates/engine's managed.rs promises keep running. On Linux a process started detached from within a user unit is now started through `systemd-run --user --scope`: a transient scope of its own in the app's slice (so it still ends with the graphical session), the same process and environment. spawn_detached hands it back once systemd-run has become it, which it does once the scope exists, so an app that exits straight after doesn't take it down either. Where systemd-run gives up (no manager to reach, an option it doesn't know) or isn't there, the command is started as before. Windows leaves the app's job object for the same reason. a_detached_process_outlives_the_unit_that_started_it (ignored: it needs a systemd user manager) starts a process detached from inside a transient service that then ends, and fails without it.
Contributor
Author
|
The red checks come from
As for this change:
|
This was referenced Nov 12, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
app-Hyprland-zeron@….service), GNOME and KDE as a scope.crates/engine/src/managed.rspromises those keep running.systemd-run --user --scope.spawn_detachedhands it back only oncesystemd-runhas become it, which happens once the scope exists, so an app that exits straight after doesn't take it down either. This costs about 3 ms.systemd-runmissing: the spawn fails, and the command is started as before.systemd-rununable to create the scope: it exits before running the command, still namedsystemd-run, which is detected, and the command is started as before.systemd-run(process spawning, please review closely):--slice=names the app's own slice rather than--slice-inherit(systemd ≥ 251), so older systemd works.--collectneeds systemd ≥ 236.spawn_detachedcaller:launch(), used by the zgx app, the GPUI app and the CLI.relaunch_self: its successor gets a new scope in the same slice.crates/update's ownspawn_detachedis unchanged.Test plan
cargo test --locked -p zeron-launch: 9 passed.systemd-runcommand line, environment and directory carried over.systemd-runscripts that become the command or give up.cargo test -p zeron-launch -- --ignored outlives): passes on CachyOS (systemd 262, Hyprland under uwsm). With the scope step removed it fails: "the detached process went down with the service".setsidchild of a transient user service is killed when the service's main process exits. Started throughsystemd-run --scope, it survives.cargo clippy --locked -p zeron-launch --all-targets,cargo check -p zeron-engine -p zeron-cli.setsidhook moved unchanged intonew_session. The new code is#[cfg(target_os = "linux")], and the Windows branch is untouched.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.