in reply to Re: Re: Re: Update in-place with temporary file and flocking
in thread Update in-place with temporary file and flocking

I may have misread/understood your code, but in order to be able to open and lock file1 wouldn't it have to be:
copy "file1", "file2"; # instead of move my $fh = new IO::File("file1","w") flock($fh,LOCK_EX) or die "can't get lock"; my $fh2 = new IO::File("file2","r"); #read fh2 write to $fh flock($fh,LOCK_UN); # perhaps delete file2
With the rename, even if we could create a file1 to subsequently lock, wouldn't there'd be a small gap where a program could attempt to get read access to file1 and find it not there...