one-copy: answer at once when the lock's holder is running #2
Loading…
Reference in a new issue
No description provided.
Delete branch "holder-alive-answers-at-once"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A second copy of a running app is now told at once instead of after 5 seconds: a terminal app's second copy printed
<name> is already openafter about 5.1 s, and a second String Lab waited 5 s before bringing the running window forward. Work package AHT-218, under FP-17.What changes (Go and Rust, same behavior)
Local\one-copy-<name>-pidand answersAlreadyOpenat once when that process is running and is the same program. Running means it opens (SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION),WaitForSingleObject(h, 0)times out, andGetExitCodeProcessis stillSTILL_ACTIVE. Same program means the image's file name fromQueryFullProcessImageNameW, compared without its folder or case, matches this process's own.claim_or_focusbrings the window forward at once.u32), so a Go app and a Rust one read each other's.flockrecords no holder.Why the exit code check is there. A holder killed by
TerminateProcessstays unsignaled for a while with its mutex still held. Over 200 runs measured here, every terminated holder showed that window, and its exit code was already set in every sample. A wait check alone would have refused the new copy during tmux'srespawn-pane -kupdate of looper and tuner. With only the wait check, the new terminated-holder test fails 3 of 3 runs.Tests. Both languages: a holder terminated at the moment of the claim, with its lock taken (the respawn case). Windows: a running child holder answered in under 1.5 s (it takes about 10 ms); the holder's recorded id read back; and a held mutex waited for, then taken once released, in three cases: no id, the id of a process that has ended, and the id of a running
cmd.exe. The old in-process "holder ends" test is gone: on Windows an in-process holder now counts as running. Each new test fails with its check removed. Go runs on Linux too (in WSL); Rust's Linux and macOS builds pass clippy.Merging releases v0.1.1. The README's pins move to it; the crate's
Cargo.tomlversion stays 0.1.0, as in the other modules.