Re:POSIX close(2) is broken
by eis on Saturday December 17, 2011 @08:37AM
(#3364204)
Only locking the close() is not enough. Another thread could still get the same file descriptor through whatever syscall while you loop around the close(). You would need to lock all syscalls that create or close a file descriptor which is a) infeasable and b) way too slow.
In other words: it's a race condition between allocating and deallocating a fd and not between two deallocations.
In other words: it's a race condition between allocating and deallocating a fd and not between two deallocations.