Fix silently-lost reboot in omarchy-system-reboot#6107
Open
jondkinney wants to merge 1 commit into
Open
Conversation
omarchy-system-reboot scheduled the reboot as `nohup bash -c "sleep 2 && systemctl reboot" &`. That child inherits the cgroup of the terminal's transient systemd scope (app-*.scope, created with --collect). The script then closes all windows, including its own terminal, which makes systemd stop and collect that scope and SIGTERM every remaining process in it -- including the still-sleeping reboot child. nohup only blocks SIGHUP, not the scope's SIGTERM, so when the teardown wins the 2s race the reboot is never issued and fails silently (nothing reaches logind). Launch the delayed reboot as a transient user unit instead. It runs in its own cgroup under the user manager, independent of the terminal scope, so it survives window-close-all and reliably issues the reboot. Verified the logind reboot is still permitted without a polkit prompt from a `systemd-run --user` unit (CanReboot returns "yes"; the unit keeps its XDG session). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
omarchy reboot(and the reboot prompt afteromarchy updatewhen the kernel was upgraded) sometimes does nothing — it closes all your windows and then just sits there, no reboot, no error.The cause is a race in
omarchy-system-reboot:The reboot is a backgrounded child, so it inherits the cgroup of the terminal's transient systemd scope (
app-*.scope, created byxdg-terminal-execwith--collect). The very next line closes all windows — including the terminal running this script. When that terminal exits, systemd stops and collects the scope, sendingSIGTERMto every process still in the cgroup, including the still-sleeping reboot child.nohuponly blocksSIGHUP, not the scope'sSIGTERM.So it's a 2-second race between the
sleep 2and the scope teardown. When the teardown wins,systemctl rebootis never reached and the reboot is lost silently — nothing reaches logind at all.I hit this in the wild: an
omarchy updateupgraded the kernel, prompted to reboot, I confirmed, and nothing happened (no logind/polkit entry whatsoever). Re-runningomarchy update— a no-op package-wise — re-prompted (because the trigger is running-kernel ≠ installed-kernel, still true) and that time the race went the other way and it rebooted.Fix
Launch the delayed reboot as a transient user unit via
systemd-run --userinstead of a backgrounded child. The unit lives in its own cgroup under the user manager, independent of the terminal's scope, so it survivesomarchy-hyprland-window-close-alland reliably issues the reboot.systemd-run --user --collect --quiet bash -c "sleep 2 && systemctl reboot --no-wall"Verification
Confirmed the logind reboot is still permitted without a polkit prompt from inside a
systemd-run --userunit:CanRebootreturns"yes"and the unit retains its XDG session, so behavior is identical to the old path minus the race.🤖 Generated with Claude Code