Repository navigation
Conversation
…com#11508) Two concurrent stops (double Alt+Print) both read /tmp/omarchy-screenrecord-filename before either removes it, posting duplicate toasts and racing over the preview. If second starts after first removes file, it reads empty name and posts broken thumbnail "-preview.png". - Add flock -n on /tmp/omarchy-screenrecord.lock at top of stop_screenrecording - Check for empty filename after reading RECORDING_FILE and skip duplicate finalize/notification - Ensure lock fd is closed on all exit paths
…com#11508) Static regression suite for the stop race: the flock guard runs before the recorder is signaled, losing the race returns quietly, an empty recording filename skips finalize and the saved toast, and the lock releases on every exit path including the RETURN trap. Asserted via source pins the way the other capture tests do, since the race depends on SIGKILL timing between the panel teardown and the EXIT trap that a harness cannot reproduce meaningfully. Verified the suite fails against packaged 4.0.3, which lacks the guard.
|
Added a regression suite pinning the stop mechanics ( |
|
Status check — this one has no review yet, so flagging that it's waiting rather than stuck. Two files: What the suite pins: the stop is single-flight via Happy to split it, reshape it, or add anything if the approach isn't what you'd want. |
A fixed name in /tmp is one any other local account can create first, and a lock file this user cannot open makes flock fail, so every stop returns quietly and the recording cannot be stopped. The per-user runtime directory is where omacom#8374 moved the rest of the recorder's state for the same reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only start creates RUNTIME_DIR. If stop runs where it is missing, the redirect fails, flock fails on the closed descriptor, and stop returns as if it had lost the race, so the recorder is never signalled and the recording cannot be stopped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
The lock was held through finalize_recording, which re-encodes or normalizes audio and can run for a long time after the recorder has exited and the indicator has cleared. A recording started in that window could not be stopped: its stop lost the lock and returned quietly. The final rm could also delete that new recording's state file. Stop now reads and removes the recording file, releases the lock, and finalizes the name it read, so finalize_recording takes the path as an argument instead of re-reading shared state. Releasing before the preview cleanup is forked also keeps that background sleep from inheriting the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
Reviewed and verified on a disposable Omarchy worker, with a second opinion from Codex Medium. The race in #11508 is real and taking a lock before signalling the recorder is the right fix. I pushed four commits to this branch to fix three problems with the lock itself, and brought the branch up to date with Reproduction. On the worker I stubbed a recorder that takes 1.5s to drain after SIGINT and ran two What I pushed
Codex Medium found the last two problems. Its final round on 35a0ba6 found nothing left open. Tests on the worker. Notes for the maintainer.
Waiting on the maintainer. |
|
| mkdir -p "$RUNTIME_DIR" | ||
| exec 9>"$RUNTIME_DIR/omarchy-screenrecord.lock" | ||
| if ! flock -n 9; then |
There was a problem hiding this comment.
Lock failure prevents stopping If the runtime directory cannot be created or the lock file cannot be opened—for example, if its permissions change while a recording is active—
exec 9> exits the shell before pkill -SIGINT runs. The recording keeps running instead of stopping. Handle directory creation and lock-open failures explicitly.
| # broken "-preview.png" thumbnail. The race involves SIGKILL timing between the | ||
| # panel's Process teardown and the script's EXIT trap, which cannot be asserted | ||
| # meaningfully from a test harness, so this suite pins the mechanics statically | ||
| # the way the other capture tests assert source contents: the flock guard, the |
There was a problem hiding this comment.
Concurrent stops remain untested The new test checks the script’s text but never runs two overlapping stops. It can pass even if the lock no longer prevents duplicate finalization and notifications. A test with a controllable recorder and competing stop calls would protect the behavior this PR is meant to fix.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Re-reviewed now that this branch conflicts with Why it conflicts. e1b0e5e (#14431) rewrote Reproduction, on a disposable Omarchy worker. I used the same stub as last time: a recorder that keeps draining after SIGINT, then two invocations 0.4s apart. I ran it with drains of 1.5s and 0.5s, both on each side of the new
Don't port it by hand either. On A smaller case is still open on Waiting on the maintainer: close this pull request and #11508 as fixed by #14431, or ask for the empty-filename guard separately. |
|
#15073 has merged, and it covers the case my last comment left open. When there is no saved recording, for example after stopping a recorder this script didn't start, stop no longer posts "Screen recording saved" with an empty name and a I compared this branch with
One behaviour is still different. When a second Opus 5.5 and Codex Medium reviewed this against current Waiting on the maintainer: close this as fixed by #14431 and #15073, or ask for an immediate, successful return from an overlapping stop as a separate change to the outer lock. |
Fixes #11508
Two concurrent
stop_screenrecordingcalls (slow encoder drain 2-3s at 4K) both read/tmp/omarchy-screenrecord-filenamebefore either removes it, posting duplicate "Screen recording saved" toasts and racing over-preview.png" (broken thumbnail). If second starts after first removed file, it reads empty name and posts-preview.png".bin/omarchy-capture-screenrecording:204— addflock -n /tmp/omarchy-screenrecord.lockat top ofstop_screenrecordingto make it single-flight (suggestedexec 9>...; flock -n 9 || return 0)RECORDING_FILEand skip duplicate finalize/notificationRepro:
omarchy-capture-screenrecording --fullscreen --resolution=3840x2160; sleep 5; stop & sleep 0.4; stopno longer posts two toasts.