Subject: Re: fifo & stdio ?
To: Hubert Feyrer <feyrer@rfhs8012.fh-regensburg.de>
From: Doug Clements <doug_clements@eee.org>
List: netbsd-users
Date: 06/13/1999 11:22:29
At 11:05 AM -0700 6/13/99, Hubert Feyrer wrote:
>Hello,
>
>I'm currently debugging gqmpeg's ipc system, and there's something I don't
>understand; maybe someone here can help me. I have an open file descriptor
>from a fifo (open(2)'ed with O_NONBLOCK), and i get a file pointer via
>fdopen(3) from that descriptor. I then want to check periodically if
>there's some data in the pipe, and do something else if not ("oink", in
>the program below).
>
>What I don't understand now is why I do not get any data when (trying to)
>read any available data with fgets(). feof() says we're at EOF after(!)
>the first call to fgets(), and doesn't change it's mind even after I send
>some data to the fifo ("echo bla >fifo.pipe").
>
>Is it possible our stdio is mixing something up here WRT pipes,
>buffering, eof, ...?
I don't think EOF gets reset automatically after more data comes into the
file. You have to find the function that will clear that (I've long
forgotten it), and let you pull stuff in. It was something like reset() or
clear(). Also, EOF doesn't get set until after trying to get something from
the file. This would explain why you only get errors after trying to read.
So I guess just try resetting the file for now, but you will need to try to
read something before you check for EOF. I hope this helps, but there's no
guarantee I'm even right =)
--Doug
doug_clements@eee.org