in reply to Safe Counter

A common error is to open() a file for writing before calling flock(). In that case, the file's contents are wiped by the open() before flock() checks if it's locked or not, by which time it's too late.

Of course, it's impossible to tell what your problem is without seeing any code.

Replies are listed 'Best First'.
Re: Re: Safe Counter
by Anonymous Monk on May 06, 2004 at 15:03 UTC
    Yes. That is exactly what I do (and that's what I've learned from books) - that a file must first be opened and then flock can be called. If this is not the proper way of using flock, what is?