xref: /dflybsd-src/lib/libstdbuf/libstdbuf.3 (revision 3856b4349e5085541ea478c27f7a5568881d43b9)
1ec21d9fbSAaron LI.\" Copyright (c) 2012 Jeremie Le Hen <jlh@FreeBSD.org>
2ec21d9fbSAaron LI.\" All rights reserved.
3ec21d9fbSAaron LI.\"
4ec21d9fbSAaron LI.\" Redistribution and use in source and binary forms, with or without
5ec21d9fbSAaron LI.\" modification, are permitted provided that the following conditions
6ec21d9fbSAaron LI.\" are met:
7ec21d9fbSAaron LI.\" 1. Redistributions of source code and documentation must retain the above
8ec21d9fbSAaron LI.\"    copyright notice, this list of conditions and the following disclaimer.
9ec21d9fbSAaron LI.\" 2. Redistributions in binary form must reproduce the above copyright
10ec21d9fbSAaron LI.\"    notice, this list of conditions and the following disclaimer in the
11ec21d9fbSAaron LI.\"    documentation and/or other materials provided with the distribution.
12ec21d9fbSAaron LI.\"
13ec21d9fbSAaron LI.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14ec21d9fbSAaron LI.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15ec21d9fbSAaron LI.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16ec21d9fbSAaron LI.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17ec21d9fbSAaron LI.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18ec21d9fbSAaron LI.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19ec21d9fbSAaron LI.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20ec21d9fbSAaron LI.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21ec21d9fbSAaron LI.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22ec21d9fbSAaron LI.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23ec21d9fbSAaron LI.\" SUCH DAMAGE.
24ec21d9fbSAaron LI.\"
25ec21d9fbSAaron LI.\" $FreeBSD$
26ec21d9fbSAaron LI.\"
27ec21d9fbSAaron LI.Dd January 1, 2021
28ec21d9fbSAaron LI.Dt LIBSTDBUF 3
29ec21d9fbSAaron LI.Os
30ec21d9fbSAaron LI.Sh NAME
31ec21d9fbSAaron LI.Nm libstdbuf
32ec21d9fbSAaron LI.Nd preloaded library to change standard streams initial buffering
33ec21d9fbSAaron LI.Sh DESCRIPTION
34ec21d9fbSAaron LIThe
35ec21d9fbSAaron LI.Nm
36ec21d9fbSAaron LIlibrary is meant to be preloaded with the
37ec21d9fbSAaron LI.Ev LD_PRELOAD
38ec21d9fbSAaron LIenvironment variable so as to change the initial buffering
39ec21d9fbSAaron LIof standard input, standard output and standard error streams.
40ec21d9fbSAaron LI.Pp
41ec21d9fbSAaron LIAlthough you may load and configure this library manually,
42ec21d9fbSAaron LIan utility,
43ec21d9fbSAaron LI.Xr stdbuf 1 ,
44ec21d9fbSAaron LIcan be used to run a command with the appropriate environment variables.
45ec21d9fbSAaron LI.Sh ENVIRONMENT
46ec21d9fbSAaron LIEach stream can be configured independently through the following
47ec21d9fbSAaron LIenvironment variables (values are defined below):
48ec21d9fbSAaron LI.Bl -tag -width size -offset indent
49ec21d9fbSAaron LI.It Ev _STDBUF_I
50ec21d9fbSAaron LIInitial buffering definition for the standard input stream
51ec21d9fbSAaron LI.It Ev _STDBUF_O
52ec21d9fbSAaron LIInitial buffering definition for the standard output stream
53ec21d9fbSAaron LI.It Ev _STDBUF_E
54ec21d9fbSAaron LIInitial buffering definition for the standard error stream
55ec21d9fbSAaron LI.El
56ec21d9fbSAaron LI.Pp
57ec21d9fbSAaron LIEach variable may take one of the following values:
58ec21d9fbSAaron LI.Bl -tag -width size -offset indent
59ec21d9fbSAaron LI.It Qq 0
60ec21d9fbSAaron LIunbuffered
61ec21d9fbSAaron LI.It Qq L
62ec21d9fbSAaron LIline buffered
63ec21d9fbSAaron LI.It Qq B
64ec21d9fbSAaron LIfully buffered with the default buffer size
65ec21d9fbSAaron LI.It Ar size
66ec21d9fbSAaron LIfully buffered with a buffer of
67ec21d9fbSAaron LI.Ar size
68ec21d9fbSAaron LIbytes (suffixes 'k', 'M' and 'G' are accepted)
69ec21d9fbSAaron LI.El
70*3856b434SSascha Wildner.Sh EXAMPLES
71ec21d9fbSAaron LIIn the following example, the stdout stream of the
72ec21d9fbSAaron LI.Xr awk 1
73ec21d9fbSAaron LIcommand
74ec21d9fbSAaron LIwill be fully buffered by default because it does not refer
75ec21d9fbSAaron LIto a terminal.
76ec21d9fbSAaron LI.Nm
77ec21d9fbSAaron LIis used to force it to be line-buffered so
78ec21d9fbSAaron LI.Xr vmstat 8 Ns 's
79ec21d9fbSAaron LIoutput will not stall until the full buffer fills.
80ec21d9fbSAaron LI.Bd -literal -offset indent
81ec21d9fbSAaron LI# vmstat 1 | env LD_PRELOAD=/usr/lib/libstdbuf.so _STDBUF_O=L \\
82ec21d9fbSAaron LI      awk '$NF > 1' | cat -n
83ec21d9fbSAaron LI.Ed
84ec21d9fbSAaron LI.Pp
85ec21d9fbSAaron LISee also the manpage of
86ec21d9fbSAaron LI.Xr stdbuf 1
87ec21d9fbSAaron LIfor a simpler way to do this.
88ec21d9fbSAaron LI.Sh SEE ALSO
89ec21d9fbSAaron LI.Xr stdbuf 1
90ec21d9fbSAaron LI.Sh HISTORY
91ec21d9fbSAaron LIThe
92ec21d9fbSAaron LI.Nm
93ec21d9fbSAaron LIlibrary first appeared in
94ec21d9fbSAaron LI.Fx 8.4 ,
95ec21d9fbSAaron LIand was imported to
96ec21d9fbSAaron LI.Dx 5.9 .
97ec21d9fbSAaron LI.Sh AUTHORS
98ec21d9fbSAaron LI.An Jeremie Le Hen
99ec21d9fbSAaron LIimplemented the
100ec21d9fbSAaron LI.Nm
101ec21d9fbSAaron LIlibrary for the
102ec21d9fbSAaron LI.Xr stdbuf 1
103ec21d9fbSAaron LIutility on
104ec21d9fbSAaron LI.Fx .
105