Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable CLOEXEC on the open file descriptor
This prevents child processes from inheriting an open file lock, which can cause locking mechanisms to misbehave in serious ways. Ideally, we would open the file descriptor with CLOEXEC enabled, but since unix 2.8 hasn't been released yet and we want backwards compatibility with older releases, this commit sets CLOEXEC after opening the file descriptor. This may seem like a race condition at first. However, since the lock is always taken after CLOEXEC is set, the worst that can happen is that a child process inherits the open FD in an _unlocked_ state. While non-ideal from a performance standpoint, it doesn't introduce any locking bugs.
- Loading branch information