fix: keep the Linux single-instance mutex alive (#10629)

Store the named mutex in a static field. Discarding it lets the runtime release/finalize it, so a second launch no longer sees the first instance and a new process starts.
This commit is contained in:
socrabs151
2026-11-18 10:01:30 +03:00
committed by GitHub
parent 109c7fd5b3
commit c5334bc700
+4 -1
View File
@@ -6,6 +6,7 @@ namespace v2rayN.Desktop;
internal class Program
{
public static EventWaitHandle ProgramStarted;
private static Mutex? _instanceMutex;
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
@@ -38,7 +39,9 @@ internal class Program
}
else
{
_ = new Mutex(true, "v2rayN", out var bOnlyOneInstance);
// Keep the named mutex alive for the process lifetime. Discarding the handle lets
// the runtime finalize it, so the next launch sees no running instance.
_instanceMutex = new Mutex(true, "v2rayN", out var bOnlyOneInstance);
if (!bOnlyOneInstance)
{
return false;