http://qs321.pair.com?node_id=11134250


in reply to Re: singleton lock not reliable
in thread singleton lock not reliable

> 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.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery