in reply to Re^2: Trying to understand flock
in thread Trying to understand flock

We want to clobber the file, but we don't want to clobber the file until we've locked it. The catch is that one can't lock a file one doesn't have open, so we can't use open ">" to clobber the file. That means we have to start by opening the file without clobbering it (e.g. by using open ">>") and by locking it. Then, we're free to clobber it.

Replies are listed 'Best First'.
Re^4: Trying to understand flock
by toniax (Scribe) on Nov 15, 2010 at 01:52 UTC
    Thanks for the explanation. I understand now.