On Tue, 13 Dec 2005 16:38:02 +0000, (Dominic Mitchell) wrote: > On Tue, Dec 13, 2005 at 04:24:51PM +0000, Simon Wistow wrote: > > Of course flock() doesn't work across NFS. Is the only solution to > > this a flock daemon? Depending on your kernel version, it can actually appear to work on Linux. However, although it might seem that you can lock remote files, those locks are only visible to local processes. When everyone complained about the relatively recent removal of Linux's apparent flock() over NFS capability, they failed to realise that it had never really worked properly. > If you're in Perl, flock() is probably implemented using > fcntl(), which is supported over NFS. Run strace over a test > script to verify. Perl defaults to using flock() for flock(). It only falls back to using fcntl() if flock() isn't available. This is done by Configure, which doesn't actually test that flock() works, so you have to re- Configure with -Ud_flock if you want to force perl to use fcntl(). Note that the semantics are different, though; you can't get an exclusive lock with fcntl() unless you've opened the file for writing. > If it's not, then you need to do jiggery pokery with lockfiles. This > involves [complex stuff] Or you could just call fcntl() from perl. It means using unportable pack() construction of the struct flock, but it does work. -- Peter Haworth pmh@edison.ioppublishing.com "Aren't the backward compatibility police going to glue your hands to the spacebar for even proposing it?" -- Joshua N Pritikin