jlo@elan.UUCP (Jeff Lo) (05/14/88)
I need to be able to read from a pipe in no delay mode and be able to ditinguish between EOF, and cases when there is just no data, but the pipe is still open. This is no problem under 4.2 since the read() will return 0 on EOF, and if the pipe is empty, but still open on the other end, it will return -1 and set errno to EWOULDBLOCK. Under System 5 (5.2 and 5.3) the read() returns 0 in both cases. Does anybody know how to distinguish between these two cases under System 5? Jeff Lo Elan Computer Group, Inc. ..!{ames,hplabs}!elan!jlo
terry@wsccs.UUCP (Every system needs one) (05/28/88)
In article <311@elan.UUCP>, jlo@elan.UUCP (Jeff Lo) writes: > I need to be able to read from a pipe in no delay mode and be able to > ditinguish between EOF, and cases when there is just no data, but the > pipe is still open. > > This is no problem under 4.2 since the read() will return 0 on EOF, and > if the pipe is empty, but still open on the other end, it will return -1 > and set errno to EWOULDBLOCK. > > Under System 5 (5.2 and 5.3) the read() returns 0 in both cases. Does > anybody know how to distinguish between these two cases under System 5? If you're going to buzz-loop the darned thing, as you apparently are if you are using "no delay mode", you might as well do another ioctl() call to find out how many characters are pending. Some systems will tell you -1 if it's at EOF. The other alternative might be to stat it... again, some implementations return EOF conditions. It would probably be a nice idea if you were to tell us what you need it for, and we could suggest alternatives. For instance, a signal or a magic cookie down the pipe might be the way to go. | Terry Lambert UUCP: ...{ decvax, ihnp4 } ...utah-cs!century!terry | | @ Century Software OR: ...utah-cs!uplherc!sp7040!obie!wsccs!terry | | SLC, Utah | | These opinions are not my companies, but if you find them | | useful, send a $20.00 donation to Brisbane Australia... | | 'Admit it! You're just harrasing me because of the quote in my signature!' |