|Pathologically Eclectic Rubbish Lister|
Re^2: singleton lock not reliableby LanX (Sage)
|on Jun 24, 2021 at 09:51 UTC||Need Help??|
> The FAQ is explicit is stating that the filehandle must be opened for writing (or appending or read+write)
it depends on the implementation, the perldocs refer to multiple different OS functions potentially used for flock and say
lockf(3) does not provide shared locking, and requires that the filehandle be open for writing (or appending, or read/writing).
So yes, it's possible that some Perl ports will fail when opening with < , if Perl was compiled to use lockf
Personally I'm doing it deliberately on WIN (where it works) to make sure my colleagues understand that the lockfile is an empty semaphore only. (Opening for writing with > has it's own hazards, because the content will be deleted each time.)
It really depends on the OS and FS and should be tested for each combination.