---
name: "libstdbuf"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/libstdbuf"
---

# libstdbuf(3)

preloaded library to change standard streams initial buffering

## 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 to 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)](/stdbuf/1.md), 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)

## EXAMPLE

In the following example, the stdout stream of the [awk(1)](/awk/1.md) 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)](/vmstat/8.md)'s output will not stall until the full buffer fills.

```
# vmstat 1 | LD_PRELOAD=/usr/lib/libstdbuf.so \
    STDBUF_1=L awk '$2 > 1 || $3 > 1' | cat -n
```

See [stdbuf(1)](/stdbuf/1.md) for a simpler way to do this.

## SEE ALSO

[rtld(1)](/rtld/1.md), [stdbuf(1)](/stdbuf/1.md)

## HISTORY

The **libstdbuf** library first appeared in FreeBSD 8.4.

## AUTHORS

The original idea of the **libstdbuf** command comes from Padraig Brady who implemented it in the GNU coreutils. Jeremie Le Hen implemented it on FreeBSD.
