How do I recover my pipe on my Parent's Death?

Jonathan I. Kamens jik at athena.mit.edu
Thu May 23 01:05:07 AEST 1991


  First of all, I don't see any code there where you properly initialize
readfds to tell select() which file descriptors you are interested in.  Are
you doing that?

  Second, why are you using an FIONREAD ioctl to check each file descriptor,
when select() will tell you in readfds (that is, after all, why you pass it a
pointer to the fd_set -- so that it can modify it) which file descriptors it
has determined are ready to be read?  Of course, this means that you have to
reinitialize readfds each time you call select(), which brings us back to the
first paragraph above.

  Third, select() indicates that a file descriptor has reached EOF by
indicating that it is ready to be read.  You are expected to then read() the
file descriptor, notice that read() returns 0, and conclude that the file
descriptor has reached EOF, at which point you should close it and remove it
from the list of descriptors that select() examines.

  The ioctl() you are doing is completely correct in returning 0 in response
to FIONREAD on a descriptor which has reached EOF -- if it's at EOF, there is
no data to be read on it.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list