Closed as duplicate of#48720
Description
Description
Acquiring a global named mutex doesn't seem to work on MacOS and Linux when the application is compiled with NativeAOT.
Reproduction Steps
internal static class Program
{
private static void Main(string[] args)
{
using (var mutex = new Mutex(false, "Global\\{604074dc-be47-4a35-b79d-b79eead0c022}"))
{
mutex.WaitOne();
Console.WriteLine("The app is now running...");
Console.ReadLine();
}
}
}
Compile to native using the following:
dotnet publish --configuration Release --runtime osx-x64 --output dist
Expected behavior
The second instance of the program blocks and waits until the first has terminated
Actual behavior
The second instance successfully acquires the mutex.
Regression?
No response
Known Workarounds
No response
Configuration
- .net 8
- MacOS and Linux (ubuntu 24)
- x64
Other information
The same works if the application is not compiled to native code but simply build in release mode:
dotnet build --configuration Release