有人说,flock()
(BSD-locks)和fcntl()
(POSIX record-level locks)给用户提供了不兼容的语义,特别是在锁释放方面。
然而,在glibc
中,flock()
是基于POSIX fcntl()
实现的。(我在官方git repo上检查了这一点,这里只是可查看的链接)
https://code.woboq.org/userspace/glibc/sysdeps/posix/flock.c.html#18
/* This file implements the
flock' function in terms of the POSIX.1
fcntl' locking mechanism. In 4BSD, these are two incompatible locking mechanisms, perhaps with different semantics? */
如何理解这些事实呢?