You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 08b1cc7
Browse filesBrowse the repository at this point in the historyBrowse files
fix(instance-gate): exclusive between processes on Linux and macOS
The pipe was the lock only on Windows. .NET's Unix named-pipe server is a
Unix-domain socket that unlinks whatever socket is at its path and binds
its own, and it enforces maxNumberOfServerInstances only within one process
(NamedPipeServerStream.Unix.cs, SharedServer). So a second process claimed
the gate instead of being refused: every launch held it, a hand-off reached
the newest window, and the older gate's dispose unlinked the newer one's
socket.
Off Windows the claim is now an exclusive advisory lock (flock, which .NET
takes for FileShare.None) on <channel>.claim in the temporary folder, held
for the gate's life and released after the server is disposed. The kernel
drops it when the process dies however it dies, so a crash leaves no stale
claim, which FirstPipeInstance alone would: its bind fails on a dead
holder's socket file for good.
The existing exclusivity test held both claims in one process, where .NET
refuses the second server by itself, so it passed on Linux all along. Two
new tests hold the gate from a second process (the test assembly run again,
claiming in a module initializer): another process's claim refuses this
one and still takes its hand-off, and a killed holder leaves the claim
free. The first failed on Linux (WSL, Ubuntu 24.04, .NET 10.0.112) before
the lock and passes three runs in a row after it; Windows passes both ways.
Found by TianWen's review #1414.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YTPcimK4UctQtAyuNCZy3z
0 commit comments