LIBSTDBUF(3)

NAME
libstdbuf - preloaded library to change standard streams initial buffering

DESCRIPTION
The libstdbuf library is meant to be preloaded with the LD_PRELOAD environment variable so as to change the initial buffering of standard input, standard output and standard error streams.

Although you may load and configure this library manually, an utility, stdbuf(1), can be used to run a command with the appropriate environment variables.

ENVIRONMENT
Each stream can be configured independently through the following environment variables (values are defined below):

_STDBUF_I
    Initial buffering definition for the standard input stream

_STDBUF_O
    Initial buffering definition for the standard output stream

_STDBUF_E
    Initial buffering definition for the standard error stream

Each variable may take one of the following values:

"0" unbuffered

"L" line buffered

"B" fully buffered with the default buffer size

size
    fully buffered with a buffer of size bytes (suffixes 'k', 'M' and 'G' are accepted)

EXAMPLES
In the following example, the stdout stream of the awk(1) command will be fully buffered by default because it does not refer to a terminal. libstdbuf is used to force it to be line-buffered so vmstat(8)'s output will not stall until the full buffer fills.

    # vmstat 1 | env LD_PRELOAD=/usr/lib/libstdbuf.so _STDBUF_O=L \
          awk '$NF > 1' | cat -n

See also the manpage of stdbuf(1) for a simpler way to do this.

SEE ALSO
stdbuf(1)

HISTORY
The libstdbuf library first appeared in FreeBSD 8.4, and was imported to DragonFly 5.9.

AUTHORS
Jeremie Le Hen implemented the libstdbuf library for the stdbuf(1) utility on FreeBSD.