Boost logo

Boost Users :

Subject: Re: [Boost-users] [interprocess] named mutex clean up
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-04-07 18:46:10


Chard wrote:
> Does calling named_mutex::remove() have consistent cross-platform behaviour?

No until the next Boost version. The UNIX behaviour will be the chosen
behaviour: you can remove in-use named resources (named mutex, shared
memory...)

> On the Windows platform, I've found I can call named_mutex::remove() at
> start up, which seems to clean up the named_mutex if it is orphaned, or just
> do nothing if another, active, process has a lock - exactly the behaviour I
> require.
>
> However, is this platform independent, and a suitable technique?

No, it's not portable. I think you should use file locks which are
automatically unlocked when a process dies. However, take in care that
to achieve portable file locks you have several restrictions that I
think you can avoid in your case:

http://www.boost.org/doc/libs/1_38_0/doc/html/interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.file_lock

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net