redirected output is buffered, how do you flush it?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Feb 11 10:12:42 AEST 1991


In article <1991Feb10.081651.24841 at uwbln.uniware.de> jde at uwbln.uniware.de (Jutta Degener) writes:
> > Here's a very easy general solution: Run % pty script > some_file
> When you hit '^C', both the shell and its subprocess, awk, are killed.
> Unfortunately, as Tom already mentioned, awk doesn't flush its buffers.

Fortunately, a program running under pty sees a terminal for its input
and output, so any program using stdio (including awk) will flush its
buffers just as if you ran it without redirection. That's why it's a
solution.

> trap "" 1 2 3 .. etc will ignore signals for both a shell and its 
> subprocesses. (On the systems I checked.)

That won't solve the poster's problem. He's saying ``output is buffered,
so when I kill awk, I lose output.'' Tom and I are saying ``so don't
buffer your output.'' You're saying ``so don't kill awk.''

---Dan



More information about the Comp.unix.questions mailing list