Re: Trouble with UNIX pipes

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 03/31/04


Date: Wed, 31 Mar 2004 00:56:54 -0500

In article <c4cp97$n3d$1@news.cc.tut.fi>,
 Gergely Korodi <gergely.korodi@tut.fi> wrote:

> Hi,
>
> I'm trying to write a front-end for programs that read their standard
> input and write the result to standard output. I'd do this by forking a
> process and exec'ing the program; communication would be done by
> anonymous pipes (my first try). Yet nothing seems to work, as if the
> pipes would stall indefinitely (exact error seems to depend on what
> program I actually call. Sometimes one cycle of reading-writing works,
> but nothing more).

The program you're running probably uses stdio, and by default stdout is
fully buffered. This means that it doesn't send anything to the pipe
until the stdio buffer is filled, and the buffer size is typically
something like 4K bytes.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


Relevant Pages

  • Re: Trouble with UNIX pipes
    ... > input and write the result to standard output. ... > anonymous pipes. ... until the stdio buffer is filled, and the buffer size is typically ...
    (comp.unix.misc)
  • Re: Trouble with UNIX pipes
    ... > input and write the result to standard output. ... > anonymous pipes. ... until the stdio buffer is filled, and the buffer size is typically ...
    (comp.unix.programmer)
  • Re: Great SWT Program
    ... And the emacs term "buffer" is not identical to this. ... Emacs generally doesn't care about your own standard. ... launching "flashlight" is still carrying a concealed gun. ...
    (comp.lang.java.programmer)
  • Re: Buffer overflows and asctime()
    ... to contain a "bug" as others are not. ... standard the year member receives a maximum value. ... will overflow its buffer if confronted with valid inputs. ... So you still do not understand "undefined behavior". ...
    (comp.std.c)
  • Re: Why is it dangerous?
    ... learn that C had such weak string handling, ... Exploiting getson an auto buffer ... that omitted any standard on what could or could not be input. ... the pedants, on whose code contains more *actual* bugs. ...
    (comp.lang.c)