I have a user reporting that the following code in my application’s main() hangs unless he uses “Run as Adminstrator”:

 

       ZTRACE_RUNTIME("Checking Mutex");

       bip::named_mutex dssMutex{ bip::open_or_create, "DeepSkyStacker.Mutex.UniqueID.12354687" };

       bip::scoped_lock<bip::named_mutex> lk(dssMutex, bip::defer_lock);

       const bool firstInstance{ lk.try_lock() };

       ZTRACE_RUNTIME("  firstInstance: %s", firstInstance ? "true" : "false");


The trace shows “Checking mutex” and then it all stops.

 

Is my code in error and if so what do I need to change?  If not, how can I determine what the problem is?

 

On a related issue:  I think that this is C++ Exception safe, as the mutex will be unlocked and deleted.


However, if a C exception occurs then how should I clean up?

 

Is the named_mutex persistent over reboots?  If so, where is it held (in case I need to do a manual cleanup).

 

Many thanks

David