Forcing a flush of stdout buffer

Forcing a flush of stdout buffer

Post by Geoff Johnst » Wed, 02 Jun 1993 06:05:12



Hello,

I am writing an application that will access an existing
command-line tool.  It does so using Xt Input callbacks,
with stdin and stdout from the forked command-line tool process.

Unfortunately, the command-line tool won't seem to dump
its buffer when I pipe it to the parent (my app).  I have tried my
program on other command-line programs (e.g. bc) and it works fine.

How can I force it to dump its buffer?  I am running HPUX8.0

(Since I can't modify the command-line tool, I can't do
 an fflush from that process)

Also, why would this tool not empty its buffer when forked
and run with execlp, when it necessarily does so as a foreground
interactive application?  The only way I can seem to get a flush
is by forcing the buffer to get really full.

Many thanks,

 
 
 

Forcing a flush of stdout buffer

Post by Christoph Badu » Wed, 02 Jun 1993 08:23:28



Quote:>Unfortunately, the command-line tool won't seem to dump
>its buffer when I pipe it to the parent (my app).  I have tried my
>program on other command-line programs (e.g. bc) and it works fine.
>How can I force it to dump its buffer?  I am running HPUX8.0

Don't connect it's stdin and stdout to a pipe but to a pseudo tty.

Quote:>Also, why would this tool not empty its buffer when forked
>and run with execlp, when it necessarily does so as a foreground
>interactive application?

That's because the stdio code checks if the output device is a
terminal like device or not and only in the former case goes into line
buffering mode for all other devices it uses block buffering.

--

Personally, I don't care whether someone is cool enough to quote Doug
Gwyn--I only care whether Doug Gwyn is cool enough to quote. -- Larry Wall