I just realised it’s not hanging – it’s thrown an interprocess exception.

 

I have revised my code to capture and report on that.  I will let you know what it says.

 

David

From: David C. Partridge <david.partridge@perdrix.co.uk>
Sent: 13 November 2023 14:16
To: 'boost-users@lists.boost.org' <boost-users@lists.boost.org>
Subject: Problem with named_mutex on Windows

 

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