Repository navigation
End omarchy update when its terminal closes at a prompt - #16045
Conversation
[High impact] The PR appears safe to merge, with a non-blocking timing issue in the hangup test. SummaryThe update keeps a plain Bash process above it so losing the terminal also ends a waiting prompt.
|
|
Thanks for the careful write-up. I reviewed this, ran it on a worker, and had Codex Medium review it as a second opinion. The mechanism you describe is right, but on a stock install I could not reproduce the update staying stranded. What I ran, on a disposable worker built from the Omarchy ISO (foot, gum 2.0.2, util-linux 2.42.4). I used the real
Codex Medium agreed with the mechanism; its independence from my review is not guaranteed. It pointed out why base recovers here: util-linux One question decides what happens next: on the machine where it sat for a week, which terminal emulator was the update window in, and what do Findings in the change, none pushed while the reproduction is open:
Overlaps: #14601 and #15683 edit the same Waiting on your answer above. After that, the maintainer decides whether to take the faster shutdown on its own merits. |
|
Another reproduction with Ghostty 1.4.0+omarchy.1, gum 2.0.2, and script from util-linux 2.42.4. The update was launched through |
|
Another live occurrence on 2026-11-14: omarchy-update (PID 1725243) → omarchy-update-confirm (1725258) → gum confirm (1725299) had survived for 6 days 21 hours. The updater was reparented to PID 1515; all three were attached to /dev/pts/26 (deleted), and the updater/confirmation script still had fd 10 open on /run/user/1000/omarchy-update.lock. No script(1) ancestor or package transaction remained. Terminal emulator for the original launch is not established. Terminating only the abandoned gum with SIGTERM let the confirmation/updater exit. Independently verified flock could then be acquired; the lock file was not removed. Current installed packages: omarchy-dev 4.0.0.r7600.g6194f46-1, util-linux 2.42.4-1, gum 2.0.2-1, ghostty 1.4.0-1, foot 1.28.0-2. Important qualification: This supports the stranded-process failure mode, but is not a controlled reproduction or validation of the proposed patch. |
tobi
left a comment
There was a problem hiding this comment.
Reviewed and updated the contributor branch using maintainer edits (no force push, no merge of the PR).
Resolved against current quattro d81c2e2 while retaining the original contribution. The runtime fix remains a plain Bash PTY session leader plus trailing exit; there is no watchdog, stale-lock deletion, PID liveness heuristic or timeout-based unlock.
Addressed the earlier review findings:
- Preserve the caller’s exported SHELL, including its absence, inside the trusted Bash wrapper. Merely checking whether the Bash variable exists is insufficient: Bash synthesizes an unexported SHELL on startup.
- Private fixture runtime directory; no login-session /run/user requirement.
- Real packaged gum, script, PTYs and flock instead of an EOF-loop prompt substitute.
- Exactly one PTY-master owner; closing it really closes the terminal. All waits are bounded, zombies count as exited, and orphaned fixture children are adopted/reaped with Linux subreaper semantics. No global pkill-by-pattern cleanup.
- Added a deterministic abrupt-script-loss case. On unchanged quattro, ordinary terminal closure passes but killing script outright leaves real gum holding the lock. With this patch, both cases pass. This reproduces the missing-script-ancestor state observed on affected machines without claiming to establish why their script process originally vanished.
Also added the operator-requested diagnostic acquiring PID to the lock file. Rejected contenders preserve it and report it. The PID is explicitly informational: only flock decides exclusion, and an old PID never blocks a free flock.
Validation: update-hangup, update-lock, update-user-path, update-sequence, update-hook-security, update-stay-awake-security, and ./test/cli all pass. bash -n and git diff --check pass. New hangup test fails on unchanged quattro specifically because real gum survives abrupt script loss. No live package update or installed-file modification was performed. Full VM CI remains required; this is not an independent approval of changes I authored.
) * End omarchy update when its terminal closes at a prompt * Record the update lock acquiring PID for diagnostics --------- (cherry picked from commit 9ac0883) Co-authored-by: Santiago <shbernal.01@gmail.com> Co-authored-by: Tobi Lutke <tobi@shopify.com>
quattro's omacom#16045 records the acquiring PID in the lock file. Under this branch the wrapper is what holds the flock, so it writes its own PID there, and the stale-PID test compares against the locked command's parent rather than the command itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #16044.
Closing the update terminal while
omarchy updatewaits at its confirmation prompt can leave the updater andgumattached to a deleted PTY, still holding the update flock. A live occurrence survived almost seven days. Thescriptancestor was already gone; no package transaction had begun.Fix
Keep a plain, untrapped Bash as the session leader inside
scriptby following the updater command with; exit $?. Without that trailing command, Bash can exec the updater: its signal traps then wait for the foreground prompt, which may never receive the hangup. With the plain shell leader, terminal loss ends the leader and the kernel hangs up the foreground process group.Pin
script's interpreter to Bash because the command uses Bash quoting. Restore the caller's exportedSHELLinside that interpreter, preserving an absent export as absent, so hooks and package builds retain their environment. Preserve the updater's exit status.Record the acquiring shell's PID in the lock file for diagnostics and report it on contention. Open contenders without truncating the recorded PID. The PID is not an unlock heuristic: PIDs can be reused and children can inherit the descriptor.
flockremains the sole authority; no lock-file deletion, watchdog, polling service or timeout-based unlock is introduced.Reproduction and tests
test/shell.d/update-hangup-test.shruns real packagedgum,script, PTYs and the real lock, with all update/package/privileged steps stubbed. It covers:scriptoutright before closing the terminal, reproducing the observed missing-ancestor state without its two-second fallback cleanup.SHELLand nonzero update status.On unchanged
quattrod81c2e2, ordinary terminal closure passes, but abrupt loss ofscriptleaves realgumalive holding the lock. That regression passes with this patch. This does not establish whyscriptoriginally vanished on affected machines.The test uses a private runtime directory (no login-session requirement), bounded waits, zombie-aware exit checks, and PID-scoped subreaper cleanup. No reader child retains the PTY master and no global
pkillpattern is used.The existing lock test additionally verifies that rejected contenders preserve/report the acquiring PID and a stale diagnostic PID cannot block a free flock.
Validation
Passing locally:
update-hangup-test.sh(fails on unchanged base for the intended regression)update-lock-test.shupdate-user-path-test.shupdate-sequence-test.shupdate-hook-security-test.shupdate-stay-awake-security-test.sh./test/clibash -non changed files andgit diff --checkFull VM CI remains required. No real package update or installed-file modification was performed.
Updated through maintainer edits against current
quattro, preserving the original contribution without a force push. Related: #8081 addresses daemon-inherited flock descriptors after a completed updater, while #17020 addresses transcript truncation on contention. #14601 and #15683 touch the same logger boundary and may require coordination.