title: How to avoid scenario where Process2 keeps waiting for Process1 to release the named_mutex
body: <p>I have several processes but only one should be running at the time. This means that let's say the <strong>Process1</strong> is running and if the <strong>Process2</strong> get launched, then <strong>Process2</strong> should wait until <strong>Process1</strong> is complete. I am considering the <strong>boost named_mutex</strong> for this with code like below.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/interprocess/sync/named_mutex.hpp&gt;
  
  using namespace boost::interprocess;
  
  int main()
  {
      named_mutex mutex(open_or_create, "some_name");
  
      try
      {
          mutex.lock();
  
          // Do work
  
          mutex.unlock();
      }
      catch (const std::exception&amp; ex)
      {
          mutex.unlock();
          std::cout &lt;&lt; ex.what();
      }
  }
  </code></pre>
  
  <p>Questions:<br>
  1. I would like to make sure that there is no situation where <strong>Process2</strong> get starved of acquiring the lock if <strong>Process1</strong> encounters any handled/unhandled exception?<br>
  2. Is there any c# like finally mechanism in c++ that could be helpful in this use-case?  </p>