Boost logo

Boost :

Subject: Re: [boost] [interprocess] leaked named mutexes
From: Bjorn Reese (breese_at_[hidden])
Date: 2013-03-07 06:02:16


On 2013-03-06 23:51, Eric Niebler wrote:

> On my Linux box, this runs fine the first time, but the second time it
> hangs waiting to acquire the mutex. I have to manually delete the
> semaphore in /dev/shm/.

I do not know the specifics of named_mutex, but this is a general
problem with Unix shared memory, semaphores, and message queues. The
basic problem is that these IPC facilities are designed to be used
between processes, and sometimes you actually want them to survive a
crash, so it is difficult to make a garbage collection for them.

> - Does this clean up only this process's use of the named_mutex, or does
> it nuke it from the system, even if another process is using it? (The
> docs suggest the latter, which is not what I want, is it?)

Probably the latter. The workaround that I have been using is to get
the PID of the last process that has accessed the IPC, and check if it
is still running. If not, I remove the IPC. I was doing this with a
script, so I used the ipcs -p, ps, and ipcrm commands.


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