Subject: Re: fread, fd behavior, and perl
To: None <tech-userlevel@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 03/11/2000 13:41:16
>> perl 5.6 RC1 complains about instances where fread returns 0 but
>> neither feof or ferror are true;

> What about nonblocking reads?  wouldn't they create the above
> situation?

No, because stdio doesn't know anything about nonblocking I/O.  One
could argue that, confined to the UNIX world, it should, but presumably
the C standard - which is where stdio is specified, at least mostly -
is not just a UNIX thing.

A nonblocking read(2) that would block has only two choices, really: to
return 0 (ie, EOF), or to return an error (EWOULDBLOCK, EAGAIN,
whatever the OS in question calls it).  The former looks like EOF to
stdio; the latter looks like an error.

(So how is the original condition possible?  Go read the FreeBSD pr:
this happens with Torek stdio when you read from a write-only stream.)

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B