LD_PRELOAD
library for controlling standard stream buffer sizes.
You can grab prebuilt 32- and 64-bit binaries from the Releases tab. These are built by Travis on a CentOS 5 Docker image, so they should "just work" on any Linux distribution newer than that.
For instance, if you wished to set the stdout
of a program app
to be unbuffered when connected to a terminal
(rather than the default line-buffering), the invocation would be:
$ LD_PRELOAD=/path/to/setbufsize64.so STDOUT_BUFFER_SIZE=0 ./app
STDERR_BUFFER_SIZE
does the obvious thing, for stderr
.
Due to its nature as an LD_PRELOAD
object, setbufsize
requires the target program to use libc
for its output,
and furthermore be dynamically linked.