http://qs1969.pair.com?node_id=1008678


in reply to flock on Windows : process killed while in critical region

Hello rovf,

I believe the unlock is optional in your code. Closing the file automatically frees the lock. So if a script were to die during the critical code, then the lock would be freed as part of closing all files by Perl.

######################### # CRITICAL REGION IS HERE ######################### flock(LOCKFILE, LOCK_UN); ## optional close(LOCKFILE);

I did a 'super-search' and found this quote but not the slides that are mentioned. "...Check out the links to Dominus' File Locking Tricks and Traps slides in the Question about Flock and die thread for more details..." by converter.

For several years, I would go through the slides again, since 'flock' is very powerful and easy to forget all the "tricks" that can be used. My bookmark didn't work, so maybe the slides have been moved.

Have a good one...Ed

"Well done is better than well said." - Benjamin Franklin