Disable buffering in STDOUT
If you have an executable that writes to standard output, chances are, the code might not have controlled output buffering. If that is the case, once you redirect the output to another executable via pipe, or to a file, the output will be buffered and will not be written immediately. A more detailed write up about the problem is given here.
There is a - relatively - quick solution to this problem you can try if all else (like stdbuf or unbuffer) fails:
# echo '__attribute__((constructor))void f(){setvbuf(stdout,NULL,_IOLBF,0);}' \ | gcc -s -include stdio.h -x c - -fPIC -shared -o "line_buffer.so" # mv line_buffer.so $HOME/lib/line_buffer.so # LD_PRELOAD="$HOME/lib/line_buffer.so" executable
First we build a library that will set the stdout buffer to be line buffered, instead of fully buffered. Then we move the library to somewhere tidy. Then we use the LD_PRELOAD trick to override the default properties of stdout for the executable.
Taken from here. An explanation for the LD_PRELOAD trick can be found [here](http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick







