[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Reading from the pipe will see end-of-file when all writing descriptors have been closed



  Quoting pipe(7):

    If all file descriptors referring to the write end of a pipe
    have been closed, then an attempt to read (2) from the pipe
    will see end-of-file ( read (2) will return 0).

  Consider a pipe with 1 reading and 1 writing processes.  The
reading process was put to sleep by the scheduler after he has
opened the pipe.  The writing process currently writes 1 byte to
the pipe.  It will close the pipe immediately afterwards.  So
there is a pipe containing 1 byte, no writing processes, and 1
reading process.

Am I right that:

1. In reality, when the the reading process runs and reads the pipe,
   it will see the single byte that was written to it, followed by
   an end-of-file.
2. Strictly following the quote from above, when the reading
   process runs and reads the pipe, it should immediately see an
   end-of-file.

Therefore, pipe(7) choice of words is unfortunate.  I think a bug
should be filed.


Reply to: