It doesn't work that way. You lock the file you just opened. Search the
web - there must be a gazilion examples of this out there.
On Fri, 18 Feb 2000, Glen Lee Edwards wrote:
> I'm trying to create a lock in a Perl script using flock(). I can't get
> it to work, so I need some info on how Linux handles flock (don't send me
> to man - been there, done that, it was a wasted read).
>
> We're trying to lock a file "hitcounter" before opening it by creating a
> file "hitcounter.lock". The Perl experts are saying that we can then lock
> hitcounter.lock, which will automitically lock hitcounter:
>
> open S, ">hitcounter.lock" || die $!;
> flock S, LOCK_EX;
> open F, ">hitcounter" || die $!;
>
> In spite of what the experts say the preceding doesn't work (I spent
> several hours this evening trying it). Is there some way of telling Linux
> to lock <file> with <file.lock>?
>
> flock hitcounter LOCK_EX hitcounter.lock
>
> ???
>
> Glen
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.