True and good advise.
The programmer can also use time outs and alarms to walk out of a blocked IO call. Examples of this exist in the
perlipc documentation (man perlipc ; perldoc perlipc).
(might only work safely on UNIX though).
This will solve your retry problem too. On failing a blocking
IO operation, the cautious always pause before trying again.
Also be careful of the advisory nature of the flock. A
program is not forced to wait unless they lock and unlock
voluntarily at the correct place in their operations.