in reply to Fork + Flock = Who Gets the Lock?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fork + Flock = Who Gets the Lock?
by Fletch (Bishop) on Jun 03, 2005 at 20:09 UTC | |
by salva (Canon) on Jun 03, 2005 at 20:19 UTC |