Re: How to synchronously capture pipe output? - Unix

This is a discussion on Re: How to synchronously capture pipe output? - Unix ; "Robert Latest" wrote in message news:5uh04gF1hoialU1@mid.dfncis.de... > I've written two little test programs to illustrate my point. One > ("writer") ouputs the digits 0 thru 9, each on a single line, and pauses > one second between writes. The other ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: How to synchronously capture pipe output?

  1. Re: How to synchronously capture pipe output?

    "Robert Latest" wrote in message
    news:5uh04gF1hoialU1@mid.dfncis.de...
    > I've written two little test programs to illustrate my point. One
    > ("writer") ouputs the digits 0 thru 9, each on a single line, and pauses
    > one second between writes. The other one ("reader") captues the writer's
    > output via popen() and dumps the output.
    >
    > For some reason, the reader waits for the writer to output everything and
    > then processes the output all at once., but what I actually want is that
    > the reader proceeses the writer's output at the pace it is generated.


    The "some reason" is that the writer, or more specifically the stdio
    routines running in the writer's process, detect that stdout is not
    connected to a terminal and therefore use full buffering.

    Using a pseudo-terminal (man openpty) would likely result in line buffering,
    which is the best you can do without modifying the source of the writer.

    Alex



  2. Re: How to synchronously capture pipe output?

    Alex Fraser wrote:

    > Using a pseudo-terminal (man openpty) would likely result in line buffering,
    > which is the best you can do without modifying the source of the writer.


    Thanks, Alex, and everybody else,

    I got it to work now using the pty thingy.

    robert

+ Reply to Thread