Boost logo

Boost :

Subject: Re: [boost] [interprocess] locked mutex and process killed
From: Edouard A. (edouard_at_[hidden])
Date: 2009-03-24 06:08:59


On Mon, 23 Mar 2009 23:57:19 +0100, "vicente.botet"
<vicente.botet_at_[hidden]> wrote:
> Hi,
>
> what happens when a process owning interprocess::mutex is killed? is the
> mutex unlocked before the process dies?

After a quick look at the source code:

inline void interprocess_mutex::lock()
{
   if (pthread_mutex_lock(&m_mut) != 0)
      throw lock_exception();
}

The answer to your question is "an exception will be thrown" since the call
will return "EOWNERDEAD".

Generally speaking when a thread terminates while holding a mutex, the
mutex is considered abandoned and shared resources protected by the mutex
are in an undetermined state. Hope you like quantum physics. ;)

-- 
EA

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk