in reply to Re: Re: Can flock occasionally fail on systems that support file locking?
in thread Can flock occasionally fail on systems that support file locking?

Suppose you have two processes that work with the same lock file and each take 5 minutes to complete. One process starts up, locks the file, and then proceeds to do whatever it's designed to do. A second instance of this process is then started by some other user a minute later. This instance will call flock(), which will block and wait until the first instance releases the lock. If during this time this second instance is interrupted by a signal; e.g, ALRM, INT, etc., flock() will return and $! will be set to "Interrupted system call" (IIRC). If your program does not check the return value and continues to run, it'll clobber the file.

--perlplexer
  • Comment on Re: Can flock occasionally fail on systems that support file locking?

Replies are listed 'Best First'.
Re: Re: Can flock occasionally fail on systems that support file locking?
by rzward (Monk) on Jul 11, 2003 at 19:13 UTC

    Thank you for the clarification.

    I think this is just what I need. I'm adding error handling around the calls to flock and will check for this.

    Richard