$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [interprocess] named mutex clean up
From: Chard (boost_at_[hidden])
Date: 2009-04-08 16:00:00
"Ion Gaztañaga" <igaztanaga_at_[hidden]> wrote in message 
news:49DBD7B2.1060908_at_gmail.com...
>
> 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:
I've been trying an approach using file locks, and, as you say, the lock 
will be released should the process die.  However, other issues arise as 
regards cleaning up the file used for the lock: who creates it, and who 
deletes it?
Clearly, for the creation case, the file could be created if it didn't 
exist - though there's a potential race condition.
The deletion case is also tricky: a process figures out it is the only one 
(by getting the exclusive file lock) and then deletes the file (under 
Windows this will 'mark' the file for deletion when the last handle is 
released, i.e. the file lock).  Before the file 'truly' disappears, another 
process starts up and attempts to get a shared lock on the file...this will 
fail (certainly on Windows).
I could just leave the file around, but it's not very clean.
Is there another approach?