"be consistent" | |
PerlMonks |
Re: singleton lock not reliableby hippo (Bishop) |
on Jun 23, 2021 at 22:22 UTC ( [id://11134223]=note: print w/replies, xml ) | Need Help?? |
You are trying to obtain an exclusive lock on a filehandle that you've opened for reading. I am no expert on file locking but I don't think that's possible. The FAQ is explicit is stating that the filehandle must be opened for writing (or appending or read+write) when using lockf at least. Perhaps that is the cause of your problem. The canonical example in the Monastery is Highlander - allow only one invocation at a time of an expensive CGI script and that also uses a writing filehandle. I suggest you try switching to a writing filehandle (obviously not on $0) and see if that enables the lock for you reliably across your various OSes. 🦛
In Section
Seekers of Perl Wisdom
|
|