2 replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
source | link

Many (most?) programs, and practically all C or C++ programs, 'fully' buffer stdout when it is a pipe or disk file, or in general not isattty(), and any output still in the buffer and not flushed to the OS when you kill it is lost. Programs normally do NOT do this buffering for stderr, which is why that works.

In general use stdbuf -oL program ... or possibly -o0. Some programs have their own private options e.g. GNU sed has -u/--unbuffered.

Alternatively use something that runs the program under a pty and thus turns off buffering, including script, screen, expect or its simplified form unbuffer, or ssh -t.

For more details and options see http://unix.stackexchange.com/questions/25372/turn-off-buffering-in-pipeTurn off buffering in pipe

Many (most?) programs, and practically all C or C++ programs, 'fully' buffer stdout when it is a pipe or disk file, or in general not isattty(), and any output still in the buffer and not flushed to the OS when you kill it is lost. Programs normally do NOT do this buffering for stderr, which is why that works.

In general use stdbuf -oL program ... or possibly -o0. Some programs have their own private options e.g. GNU sed has -u/--unbuffered.

Alternatively use something that runs the program under a pty and thus turns off buffering, including script, screen, expect or its simplified form unbuffer, or ssh -t.

For more details and options see http://unix.stackexchange.com/questions/25372/turn-off-buffering-in-pipe

Many (most?) programs, and practically all C or C++ programs, 'fully' buffer stdout when it is a pipe or disk file, or in general not isattty(), and any output still in the buffer and not flushed to the OS when you kill it is lost. Programs normally do NOT do this buffering for stderr, which is why that works.

In general use stdbuf -oL program ... or possibly -o0. Some programs have their own private options e.g. GNU sed has -u/--unbuffered.

Alternatively use something that runs the program under a pty and thus turns off buffering, including script, screen, expect or its simplified form unbuffer, or ssh -t.

For more details and options see Turn off buffering in pipe

1
source | link

Many (most?) programs, and practically all C or C++ programs, 'fully' buffer stdout when it is a pipe or disk file, or in general not isattty(), and any output still in the buffer and not flushed to the OS when you kill it is lost. Programs normally do NOT do this buffering for stderr, which is why that works.

In general use stdbuf -oL program ... or possibly -o0. Some programs have their own private options e.g. GNU sed has -u/--unbuffered.

Alternatively use something that runs the program under a pty and thus turns off buffering, including script, screen, expect or its simplified form unbuffer, or ssh -t.

For more details and options see http://unix.stackexchange.com/questions/25372/turn-off-buffering-in-pipe