看板 DFBSD_submit 關於我們 聯絡資訊
flock locks are effective lockf locks but cover the ENTIRE range. It is not a good idea to try to combine them. Use one or the other. lockf locks (via fcntl) follow POSIX semanics, I believe, which means that when you close() a descriptor, ANY LOCK HELD BY THAT PROCESS ON THAT FILE will also be released, even if it was obtained by another descriptor. This is badly broken but its what POSIX says and what we have to do. If you are fork()ing you want to be sure that you only have one file descriptor open for the file that you intend to maintain a lock on. If you open/close the file within that same process the original lock on the still-open descriptor will be lost. For fcntl-based lockf locks. I believe flock() behaves more rationally. -Matt