in reply to
Re: Re: flock() broken under FreeBSD?
in thread flock() broken under FreeBSD?
Well I tried my code on Linux and the failure case looks a little different:
$ ./locktest & sleep 4; ./locktest
1557 waiting for previous instance(s) to exit...
1553 can't revert self lock to shared: Resource temporarily unavailabl
+ Exit 11 ./locktest
Which demonstrates that Linux doesn't have the strong preference for non-blocking requests like FreeBSD appears to have.
Having lock up-/down-grading introduce a race condition where the lock is freed first is such a horrid design choice to my mind that I didn't even consider the possibility when reading "man flock" (this is not even mentioned in Linux's extremely short version of "man flock" tho my test cases show that it is the case there as well).
Thanks for the enlightenment. Now I have one more reason to hate flock. I should find a module that provides a convenient wrapper for fcntl locks... (:
(but my friends call me "Tye")