in reply to (atl: about exceptions) RE: RE: race condition? - flock and $SIG{ALRM}
in thread race condition? - flock and $SIG{ALRM}

if you catch the exception instead of letting the process die, youŽll have to close the file yourself to get rid of the lock. Otherwise you might block other processes in the (rather rare) case the race condition occurs.

Hey, thanks - you're absolutely right. That's one bit I had completely over looked...

Good eye!

  • Comment on RE: (atl: about exceptions) RE: RE: race condition? - flock and $SIG{ALRM}

Replies are listed 'Best First'.
RE: RE: (atl: about exceptions) RE: RE: race condition? - flock and $SIG{ALRM}
by tilly (Archbishop) on Sep 19, 2000 at 22:05 UTC
    Just have the filehandle be localized or in a lexical scope. Then it will close on its own when it notices that you exited the scope it was opened in. :-)