Letīs analyze what happens, if you get an flock
and die before you can unset the alarm.
- You got the lock, so no other process will
write. Fine.
- You die before unsetting the alarm. Since
this is the first thing you do, thatīs equivalent
to a timeout before. Fine.
- What happens to the flock if your process dies?
Since it is bound to an open filehandle, which getīs
closed among process termination by the OS or even
earlier by the perl interpreter (cleanup), it will
simply vanish. The next process may claim the flock.
Fine.
So far, youīre codeīs fine. As for the reliabilty
of signals ... there is some coverage in the perldocs
and here in the monastry. I donīt have a link handy,
youīll have to try a search.
Have fun ...
Andreas
five days ītil YAPC::Europe ...
Update: BTW, using a nonblocking flock
and putting the process to sleep for a random time
would eliminate the need for signals. Try something
like three tries with varying random sleeping times,
if unsuccessful, give up (i.e. die). Adjust number
of tries and sleeping time for your needs.