Re: Reading FIFOs one character at a time

From: David Schwartz (davids_at_webmaster.com)
Date: 08/28/04


Date: Fri, 27 Aug 2004 21:51:57 -0700


"Peter Ammon" <peter_ammon@rocketmail.com> wrote in message
news:cgoeoe$5hh$1@news.apple.com...
>I would like to write a program to read a FIFO (named pipe) one character
>per invocation. When I attempt to read the first character, the writing
>process finishes its write and terminates, and the first character is
>successfully read. However, the remaining data is lost.

> (I know this because when I reinvoke the program read() blocks, and when I
> write more to the FIFO, I see the newly written data instead of the old
> unread data).

> I assume what's going on here is that more than one byte is being buffered
> in the reading program even though I am using the unbuffered open() and
> read() functions, and that extra buffered data is being discarded when the
> reading program terminates. How can I prevent this or otherwise
> accomplish what I want?

    This should work without any problems. Can you post the shortest
programs needed to reproduce the problem?

    DS