Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!deccrl!bloom-beacon!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: How do I recover my pipe on my Parent's Death? Message-ID: <1991May22.150507.9952@athena.mit.edu> Date: 22 May 91 15:05:07 GMT References: <1991May21.213431.2193@odetics.com> Sender: news@athena.mit.edu (News system) Distribution: na Organization: Massachusetts Institute of Technology Lines: 27 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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710