Subject: Re: fifo & stdio ?
To: Hubert Feyrer <hubert.feyrer@rz.uni-regensburg.de>
From: Frederick Bruckman <fb@enteract.com>
List: netbsd-users
Date: 06/14/1999 10:34:56
On Sun, 13 Jun 1999, Hubert Feyrer wrote:

>               while (fgets(buf, 1024, fp)) {
>                       printf("buf=<%s>\n", buf);i

On Mon, 14 Jun 1999, Hubert Feyrer wrote:

> BTW, I've just tested this on both Solaris (2.6/sparc) and Linux, and they
> both work fine, without the "if(feof(fp))rewind(fp);" workaround suggested
> here. I wonder if something should be adjusted here...

AfterStep seems to have a similar problem, which breaks it for
FreeBSD, too. AfterStep uses read(), but fgets(3) says fgets() can
return all the same errors as read(), so I think it's the same thing.

The "problem" is, that since the pipe is non-blocking, there's no
guarantee that any characters will be returned. fgets() could return
EAGAIN or EINTR and no characters, or it could return some number
less than you requested. It seems that EAGAIN="Resource temporarily
unavailable" is most common. This is after a select() and connect(),
on a socket, too. It might be interesting to see what perror() shows
in your program.