Repository navigation
Conversation
omarchy-update-lock used to exec the update, so every child inherited the flock. Flutter's adb daemonizes onto user systemd and kept that descriptor after the update exited, and the next omarchy update then reported that one was already running. Hold the flock in the wrapper and run the update with the descriptor closed, the same trick stay-awake already uses for the sleep inhibitor. Fixes omacom#8077
There was a problem hiding this comment.
Pull request overview
Prevents daemonized AUR children from retaining the update lock.
Changes:
- Keeps the flock in the wrapper and closes its descriptor for the update child.
- Adds daemon lock-leak regression coverage.
- Updates lock lifecycle documentation.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-update-lock |
Changes lock ownership and child execution. |
test/shell.d/update-lock-test.sh |
Tests daemonized-child lock behavior. |
docs/update-process.md |
Documents descriptor handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| `omarchy-update-lock run` keeps the flock in the wrapper process and runs the | ||
| update with that descriptor closed. AUR children that daemonize (Flutter's `adb` | ||
| is the one that showed up in the wild) would otherwise inherit the flock, survive | ||
| the update, and make every later `omarchy update` report that one is already | ||
| running. `omarchy-update-stay-awake` still starts its sleep inhibitor with the | ||
| lock descriptor closed when it has one, for the same reason: that inhibitor | ||
| outlives the step that starts it, so an update killed before cleanup would | ||
| otherwise leave it holding the flock indefinitely — blocking later updates and, | ||
| now that the notifier reads the same lock, silencing migration notifications at | ||
| every login. |
quattro rebuilt update-lock-test.sh on the sudo-boundary fixture, which runs copies of the update commands against a per-run lock name. The daemon-leak tests now run those copies and look for $update_lock_name, and sit before the standalone-boundary section because it leaves SUDO_TEST_REVOKE_FAIL exported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AGENTS.md asks for full lines in docs/, with breaks only at structural boundaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stub standing in for the pre-upgrade stay-awake helper closed OMARCHY_UPDATE_LOCK_FD unconditionally. The update no longer receives that descriptor, so the close became an ambiguous redirect and the stub never started its inhibitor. Every shipped helper guards the close; the stub now does too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Now that the wrapper waits on the update instead of exec'ing it, the wrapper is what holds the flock. A closing terminal sends SIGHUP to the whole group, and bash's default is to die at once, so the lock was freed while omarchy-update was still running its HUP trap (stay-awake stop, sudo revocation). Before, the update held the lock itself until that cleanup finished. A no-op trap keeps the wrapper alive until the update exits. Caught handlers reset on exec, so the update still sees HUP and TERM with its own traps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the careful report and fix, @kdriedger. The leak is real on What was checked, on a disposable Omarchy worker VM:
Pushed to your branch (69a777d):
Second opinion: none. The configured reviewer (Codex Medium) answered a ping but had used up its daily review budget, so only Claude Opus 5.5 reviewed this change. Next: this waits on that second review before it can be marked ready for the maintainer. |
quattro dropped the standalone sudo-boundary checks at the end of update-lock-test.sh; the lock tests from this branch stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A process the update starts keeps OMARCHY_UPDATE_LOCKED=1 after the update has finished and the lock is free, so an omarchy update started from it would skip the lock and could run beside another. held() now checks that the wrapper named in the environment is still alive with the lock file open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@kdriedger, the leak is still there on What was checked, on a disposable Omarchy worker VM, at 93ea5dd:
Pushed to your branch:
Still open: the lock is released before the update's hangup cleanup when it runs under
In Two smaller points from the review, for whoever picks this up:
Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the pushed head. Both agreed the leak is real and that this change fixes its cause. Their independence from my reading is not guaranteed. Codex found the Next: this waits on you for the signal handling. |
[Medium impact] The change affects per-user update locking and workflows that check the same lock. Cancellation through the original update PID still needs fixing before merge. Findings
SummaryThe wrapper now keeps the update lock and closes its descriptor before starting the update.
Reviews (2) · Last reviewed commit: "Record the update's PID in the lock file..." · Reviewed by Greptile |
| exec "$@" | ||
| export OMARCHY_UPDATE_LOCK_HOLDER="$$:$OMARCHY_UPDATE_LOCK_FD" | ||
| # A closing terminal signals the whole group; hold the lock until the update's own cleanup finishes. | ||
| trap : HUP TERM |
There was a problem hiding this comment.
Sending kill -TERM to the PID of OMARCHY_UPDATE_LOGGED=1 omarchy-update -y no longer stops the update. That process becomes the lock wrapper, whose new no-op trap discards the signal instead of forwarding it to the update child. The child can keep installing packages after the user requests cancellation.
Forward cancellation to the child while keeping the lock until its cleanup finishes.
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>
A contender reports "Update lock acquired by PID N", and N was the wrapper, which ignores TERM: kill N did nothing, and kill -9 N freed the lock while the update kept running. Writing the PID from a foreground subshell that then execs the command makes N the update itself, as it was before the wrapper, so TERM reaches its own traps and the lock is released only after its cleanup. Nothing is backgrounded, so Ctrl-C and stdin are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
@kdriedger, Pushed to your branch:
The What was checked, on a disposable Omarchy worker VM, at 1f3f0ca:
Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the merge, then the pushed head. On the merge, both found the PID problem above, and both concluded that the Related: #12094 and #13936 still change Next: this is verified at 1f3f0ca and waits on the maintainer. The full shell suite is red on |
Fixes #8077
omarchy-update-lockused toexecthe update, so every child inherited the flock. Flutter'sadbdaemonizes onto user systemd during AUR updates and kept that descriptor after the update exited. The nextomarchy updatethen died immediately withAn Omarchy update is already running.The wrapper now holds the flock itself and runs the update with the descriptor closed — the same thing
omarchy-update-stay-awakealready does for the sleep inhibitor.Proof
Before this change, a daemonized child of
omarchy-update-lock runkept fd 10 on$XDG_RUNTIME_DIR/omarchy-update.lockandflock -nfailed after the helper exited.After:
Overlapping-update exclusion, the sleep-inhibitor close, update sequence, and migrate-notify lock tests still pass.
./test/cliis green. Four shell files fail on this machine for reasons outside this change (noomarchy-pkgscheckout; one compositor animation check).