Today I ran into an issue with fcntl(2) file locking on Linux. A little research confirmed my fear:
The worst part however is that POSIX locks are automatically released if a process calls
close()on any (!) of its open file descriptors for that file.
The whole post is well worth a read.