Skip to content

Fix silently-lost reboot in omarchy-system-reboot#6107

Open
jondkinney wants to merge 1 commit into
basecamp:devfrom
jondkinney:fix-reboot-scope-race
Open

Fix silently-lost reboot in omarchy-system-reboot#6107
jondkinney wants to merge 1 commit into
basecamp:devfrom
jondkinney:fix-reboot-scope-race

Conversation

@jondkinney

Copy link
Copy Markdown
Contributor

Problem

omarchy reboot (and the reboot prompt after omarchy update when 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:

nohup bash -c "sleep 2 && systemctl reboot --no-wall" >/dev/null 2>&1 &
omarchy-hyprland-window-close-all

The reboot is a backgrounded child, so it inherits the cgroup of the terminal's transient systemd scope (app-*.scope, created by xdg-terminal-exec with --collect). The very next line closes all windows — including the terminal running this script. When that terminal exits, systemd stops and collects the scope, sending SIGTERM to every process still in the cgroup, including the still-sleeping reboot child. nohup only blocks SIGHUP, not the scope's SIGTERM.

So it's a 2-second race between the sleep 2 and the scope teardown. When the teardown wins, systemctl reboot is never reached and the reboot is lost silently — nothing reaches logind at all.

I hit this in the wild: an omarchy update upgraded the kernel, prompted to reboot, I confirmed, and nothing happened (no logind/polkit entry whatsoever). Re-running omarchy 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 --user instead of a backgrounded child. The unit lives in its own cgroup under the user manager, independent of the terminal's scope, so it survives omarchy-hyprland-window-close-all and 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 --user unit:

$ systemd-run --user --quiet --pipe --wait bash -c \
    'busctl call org.freedesktop.login1 /org/freedesktop/login1 \
     org.freedesktop.login1.Manager CanReboot; echo XDG_SESSION_ID=$XDG_SESSION_ID'
s "yes"
XDG_SESSION_ID=2

CanReboot returns "yes" and the unit retains its XDG session, so behavior is identical to the old path minus the race.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 18, 2026 01:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants