Re: CLONE_FILES problem.

Tom May (
Wed, 21 Aug 1996 08:58:00 -0700 (Patrick Schaaf) writes:

>>Depends on what you want to do. For files at least, I'd want the file
>>descriptor to be closed, period. This means that if thread A reads from the
>>modem and thread B wants to close things down, thread B close()s the file
>>and A notices this somehow (EOF, signal, whatever).

>I think we agreed (I did :) that the situation at hand is a programming
>error anyway, and we should only be concerned that the kernel does not crash.

>Thread A sits in read() while B closes the file. If the read() returns
>later, the next read() will result in EBADF,

Only if no other cloned thread has done an open() in the mean time
which returns the same file descriptor that close() just freed. In
that case, the read() will happily read from the newly opened file.

I recently wrote a device driver for NeXTSTEP in which a close() from
one thread forces an EBADF error on any pending reads in other
threads. This was ideal behaviour for the application I was
supporting, but I have no idea whether it would be a good thing in the
general case.