The locks are merely advisory, so both the parent and the child (and all other processes) can still read and write from the file. Therefore, the question then boils down to: Who should unlock the file? On FreeBSD, that's apparently up to you to decide:
Locks are on files, not file descriptors. That is, file descriptors duplicated through dup(2) or fork(2) do not result in multiple instances of a lock, but rather multiple references to a single lock. If a process holding a lock on a file forks and the child explicitly unlocks the file, the parent will lose its lock.
In reply to Re: Fork + Flock = Who Gets the Lock?
by ikegami
in thread Fork + Flock = Who Gets the Lock?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |