lkml.org 
[lkml]   [1996]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: CLONE_FILES problem.

Tom May <alfred!ucf-cs!netcom.com!ftom> wrote:
>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.

No, this is not the right thing to do in the general case.
Let's assume for a moment that the programmer isn't so stupid as to
need protection by the system...

What if the programmer has a thread that does nothing but close unused
files and open needed files.... and another thread that does nothing
but handle read requests in a queue. It might mark a file as "finished"
and the close thread would then close it, and open another file...
The read thread might then notice and read again from the same fd,
with the desire to get data from the new file.
How do you propose the read thread should tell the kernel that it wants
the new file instead of the old one? Open the file itself??

If a thread is using a file while another thread closes it, it is a
programming error. Nothing special should be done about this except
that the kernel shouldn't fault because of a race condition in buggy code.

Steve
ssd@nevets.oau.org

\
 
 \ /
  Last update: 2005-03-22 13:38    [from the cache]
©2003-2011 Jasper Spaans