Poettering: Revisiting how we put together Linux systems
Poettering: Revisiting how we put together Linux systems
Posted Sep 9, 2014 14:43 UTC (Tue) by foom (subscriber, #14868)In reply to: Poettering: Revisiting how we put together Linux systems by nix
Parent article: Poettering: Revisiting how we put together Linux systems
A BSD lock will block a POSIX lock, and v.v.. (At least that's what happens locally; no idea what the BSD's NFS clients do.)
Linux also had that behavior a long time ago IIRC. Not sure why it changed, that was before I paid attention.
Posted Sep 9, 2014 15:27 UTC (Tue)
by bfields (subscriber, #19510)
[Link]
If a file is locked by a process through flock(), any record within the file will be seen as locked from the viewpoint of another process using fcntl(2) or lockf(3), and vice versa. Recent linux's flock(2) suggests the Linux behavior was an attempt to match BSD behavior that has since changed?:
Since kernel 2.0, flock() is implemented as a system call in its own right rather than being emulated in the GNU C library as a call to fcntl(2). This yields classical BSD semantics: there is no interaction between the types of lock placed by flock() and fcntl(2), and flock() does not detect deadlock. (Note, however, that on some modern BSDs, flock() and fcntl(2) locks do interact with one another.) Strange. In any case, changing the local Linux behavior is probably out of the question at this point.
Huh. A freebsd man page agrees with you:
Poettering: Revisiting how we put together Linux systems
https://www.freebsd.org/cgi/man.cgi?query=flock&sektion=2
http://man7.org/linux/man-pages/man2/flock.2.html