Posix says about close(2):

        "If close() is interrupted by a signal that is to be caught, it shall 
return -1 with errno set to [EINTR] and the state of fildes is unspecified."

        What means that the file descriptor can be already closed and return 
EINTR, making the call try to close it again, while this shouldn't be a real 
problem in single-threaded programs (although would return a fake EBADF), it 
creates a real problem in multi-threaded programs as you could close other file 
descriptors that were open in the mean time. Maybe you could verify with fstat 
if is safe to close again (by comparing the ino and dev values or by receveing 
EBADF)

Reply via email to