in reply to Re^2: flock LOCK_EX not locking exclusively
in thread flock LOCK_EX not locking exclusively

Well, if your open can create files, then obviously you'll have a problem. I was assuming that open would be used with mode <.

In general, if file names can never reappear after being deleted you can use this method. That's why I say that flock generally doesn't work well with unlink.