Does it actually work? I'm porting my MTA over to Minix (because why not) and the flock that's in the library doesn't seem to know about nonblocking locks:
if I do flock(fd, LOCK_EX) followed by flock(another-fd-pointing-at-fd, LOCK_EX|LOCK_NB) the second lock succeeds (either in the same process or a different process) but if I go directly to fcntl and set write locks on a trivial region (SEEK_SET,0,1) with F_SETLKW followed by F_SETLK, the F_SETLK EAGAIN's out on me as expected.
When I look at the flock source on github (@
https://github.com/0xffea/MINIX3/blob/master/lib/libc/sys-minix/flock.c) it looks like there's no way it will ever work, given that the flock #defines maps bizarrely to the fcntl defines (LOCK_EX == F_UNLCK, so an attempt to flock() a file and that the flock implementation attempts to lock a zero-length region (which even doing a fcntl fails.)
Is the intent that flock() should not be used, or is it just bug in libc?
-david parsons