Re: Reading FIFOs one character at a time
From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 08/31/04
- Next message: John W. Kennedy: "Re: Xah Lee's Unixism"
- Previous message: Dan Mercer: "Re: equivalent to far in linux/unix"
- In reply to: Norm Dresner: "Re: Reading FIFOs one character at a time"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 Aug 2004 09:13:48 -0400
In article
<yD_Yc.536853$Gx4.202351@bgtnsc04-news.ops.worldnet.att.net>,
"Norm Dresner" <ndrez@att.net> wrote:
> "JQ" <foo@bar.com> wrote in message
> news:10j7rl0jfk8glc1@corp.supernews.com...
> > Peter Ammon wrote:
> > > 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.
> >
> > Depending on the OS, a named pipe like this has an internal kernel
> > buffer. 512 bytes, 4096 bytes, and 32768 bytes I've seen. The OS will
> > also signal the writer once the reader terminates and thus will bit
> > bucket the remaining data left in the FIFO.
> >
> > You've got two problems here, one is the indeterminate FIFO kernel
> > buffer and the other other is signals between the two processes. I
> > would suggest you use a message queue a la SysV IPC or some like to
> > accomplish what you want.
>
> You can also write an intermediate function to take the whole buffer and
> serve up a character at a time.
Since the reading program terminates after each read, this buffer would
be lost.
-- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***
- Next message: John W. Kennedy: "Re: Xah Lee's Unixism"
- Previous message: Dan Mercer: "Re: equivalent to far in linux/unix"
- In reply to: Norm Dresner: "Re: Reading FIFOs one character at a time"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]