Fade
Fade

Reputation: 85

How to get live, non-blocking output from process

I want to be able to capture the output of a cli program (before it terminates) for which I don't have the source code.

Everything I have found was either done with pipes, which to my understanding only send the output on a flush or on exit of the program. One solution I have found on Codeproject is only for Windows.

Upvotes: 1

Views: 171

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136306

You can use stdbuf to force stdout and stderr of an application to be line-buffered, even when redirected into a pipe or a file:

stdbuf --output=L --error=L <program> | ...

Upvotes: 1

Related Questions