Re: PROBLEM: I/O system call never returns if file desc is closed

Matthias Urlichs (smurf@noris.de)
Thu, 7 Jun 2001 05:25:30 +0200


At 22:35 +0100 2001-06-06, Alan Cox wrote:
> > This report describes a problem in the usage of file descriptors across
>> multiple threads. When one thread closes a file descriptor, another
>> thread which waits for an I/O on that file descriptor is not notified
>> and blocks forever.
>
>THe I/O does not block forever, it blocks until completed.

That's still "forever" if you don't specify a timeout in the select.

>The actual final
>closure of the object occurs when the last operation on it exits

Select is defined as to return, with the appropriate bit set, if/when
a nonblocking read/write on the file descriptor won't block. You'd
get EBADF in this case, therefore causing the select to return would
be a Good Thing.

A related problem is that the second thread my be inside a blocking
read() instead of a select() call. It'd never continue. :-(

HOWEVER: IMHO it's bad design to distribute the responsibility for
file descriptors between threads.
Therefore I think that this behavior is a bug, but it's not one that
needs to be fixed yesterday.

-- 
Matthias Urlichs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/