in reply to Re: Writing to files
in thread Writing to files

Also, don't unlock a locked file, ever, unless you know what you're doing - just close it and the lock will go away.

I'm inexperienced with flock and am now wondering what's going on here. Do you have an URL handy that explains why you don't unlock a file prior to closing. Or... *brainflash* buffering? Unlocking a handle doesn't flush the buffer so it introduces a race condition unless the handle is either hot (and autoflushed) or has been pre-flushed?

Replies are listed 'Best First'.
Re^3: Writing to files
by Aristotle (Chancellor) on Dec 17, 2002 at 20:02 UTC

    Ding ding ding!! Bingo. :-) See also Don't use unflock (flock 8). Ever. by merlyn.

    It isn't a 100% valid concern anymore since 5.8 (or probably 5.7) and newer Perls make sure to flush and sync when unlocking, but you may still run on an older Perl (I write code for 5.6.1 and many people haven't gotten past 5.5 yet).

    Makeshifts last the longest.