3 ms·
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
by eis 15y ago
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.