1PIPESZ(1)                        User Commands                       PIPESZ(1)
2
3
4

NAME

6       pipesz - set or examine pipe and FIFO buffer sizes
7

SYNOPSIS

9       pipesz [options] [--set size] [--] [command [argument] ...]
10
11       pipesz [options] --get
12

DESCRIPTION

14       Pipes and FIFOs maintain an internal buffer used to transfer data
15       between the read end and the write end. In some cases, the default size
16       of this internal buffer may not be appropriate. This program provides
17       facilities to set and examine the size of these buffers.
18
19       The --set operation sets pipe buffer sizes. If it is specified, it must
20       be specified with an explicit size. Otherwise, it is implied and the
21       size is read from /proc/sys/fs/pipe-max-size. The kernel may adjust
22       size as described in fcntl(2). To determine the actual buffer sizes
23       set, use the --verbose option. If neither --file nor --fd are
24       specified, --set acts on standard output.
25
26       The --set operation permits an optional command to execute after
27       setting the pipe buffer sizes. This command is executed with the
28       adjusted pipes.
29
30       The --get operation outputs data in a tabular format. The first column
31       is the name of the pipe as passed to pipesz. File descriptors are named
32       as "fd N". The second column is the size, in bytes, of the pipe’s
33       internal buffer. The third column is the number of unread bytes
34       currently in the pipe. The columns are separated by tabs ('\t', ASCII
35       09h). If --verbose is specified, a descriptive header is also emitted.
36       If neither --file nor --fd are specified, --get acts on standard input.
37
38       Unless the --check option is specified, pipesz does not exit if it
39       encounters an error while manipulating a file or file descriptor. This
40       allows pipesz to be used generically without fear of disrupting the
41       execution of pipelines should the type of certain files be later
42       changed. For minimal disruption, the --quiet option prevents warnings
43       from being emitted in these cases.
44
45       The kernel imposes limits on the amount of pipe buffer space
46       unprivileged processes can use, though see BUGS below. The kernel will
47       also refuse to shrink a pipe buffer if this would cause a loss of
48       buffered data. See pipe(7) for additional details.
49
50       pipesz supports specifying multiple short options consecutively, in the
51       usual getopt(3) fashion. The first non-option argument is interpreted
52       as command. If command might begin with '-', use '--' to separate it
53       from arguments to pipesz. In shell scripts, it is good practice to use
54       '--' when parameter expansion is involved. pipesz itself does not read
55       from standard input and does not write to standard output unless --get,
56       --help, or --version are specified.
57

OPTIONS

59       -g, --get
60           Report the size of pipe buffers to standard output and exit. As a
61           special behavior, if neither --file nor --fd are specified,
62           standard input is examined. It is an error to specify this option
63           in combination with --set.
64
65       -s, --set size
66           Set the size of the pipe buffers, in bytes. This option may be
67           suffixed by K, M, G, KiB, MiB, or GiB to indicate multiples of
68           1024. Fractional values are supported in this case. Additional
69           suffixes are supported but are unlikely to be useful. If this
70           option is not specified, a default value is used, as described
71           above. If this option is specified multiple times, a warning is
72           emitted and only the last-specified size is used. As a special
73           behavior, if neither --file nor --fd are specified, standard output
74           is adjusted. It is an error to specify this option in combination
75           with --get.
76
77       -f, --file path
78           Set the buffer size of the FIFO or pipe at path, relative to the
79           current working directory. You may specify this option multiple
80           times to affect different files, and you may do so in combination
81           with --fd. Generally, this option is used with FIFOs, but it will
82           also operate on anonymous pipes such as those found in
83           /proc/PID/fd. Changes to the buffer size of FIFOs are not preserved
84           across system restarts.
85
86       -n, --fd fd
87           Set the buffer size of the pipe or FIFO passed to pipesz as the
88           specified file descriptor number. You may specify this option
89           multiple times to affect different file descriptors, and you may do
90           so in combination with --file. Shorthand options are provided for
91           the common cases of fd 0 (stdin), fd 1 (stdout), and fd 2 (stderr).
92           These should suffice in most cases.
93
94       -i, --stdin
95           Shorthand for --fd 0.
96
97       -o, --stdout
98           Shorthand for --fd 1.
99
100       -e, --stderr
101           Shorthand for --fd 2.
102
103       -c, --check
104           Exit, without executing command, in case of any error while
105           manipulating a file or file descriptor. The default behavior if
106           this is not specified is to emit a warning to standard error and
107           continue.
108
109       -q, --quiet
110           Do not diagnose non-fatal errors to standard error. This option
111           does not affect the normal output of --get, --verbose, --help, or
112           --version.
113
114       -v, --verbose
115           If specified with --get, pipesz will emit a descriptive header
116           above the table. Otherwise, if specified, pipesz will print the
117           actual buffer sizes set by the kernel to standard error.
118
119       -h, --help
120           Display help text and exit.
121
122       -V, --version
123           Print version and exit.
124

EXAMPLES

126       pipesz dd if=file bs=1M | ...
127           Runs dd(1) with an expanded standard output pipe, allowing it to
128           avoid context switches when piping around large blocks.
129
130       pipesz -s1M -cf /run/my-service.fifo
131           Sets the pipe buffer size of a service FIFO to 1,048,576 bytes. If
132           the buffer size could not be set, pipesz exits with an error.
133
134       echo hello | pipesz -g
135           Prints the size of pipe used by the shell to pass input to pipesz.
136           Since pipesz does not read standard input, it may also report 6
137           unread bytes in the pipe, depending on relative timings.
138
139       find /proc/PID/fd -exec pipesz -gqf '{}' ';'
140           Prints the size and number of unread bytes of all pipes in use by
141           PID. If some pipes are routinely full, pipesz might be able to
142           mitigate a processing bottleneck.
143

NOTES

145       Linux supports adjusting the size of pipe buffers since kernel 2.6.35.
146       This release also introduced /proc/sys/fs/pipe-max-size.
147
148       This program uses fcntl(2) F_GETPIPE_SZ/F_SETPIPE_SZ to get and set
149       pipe buffer sizes.
150
151       This program uses ioctl(2) FIONREAD to report the amount of unread data
152       in pipes. If for some reason this fails, the amount of unread data is
153       reported as 0.
154

BUGS

156       Before Linux 4.9, some bugs affect how certain resource limits are
157       enforced when setting pipe buffer sizes. See pipe(7) for details.
158

AUTHORS

160       Nathan Sharp <nwsharp@live.com>
161

SEE ALSO

163       pipe(7)
164

REPORTING BUGS

166       For bug reports, use the issue tracker at
167       https://github.com/util-linux/util-linux/issues.
168

AVAILABILITY

170       The pipesz command is part of the util-linux package which can be
171       downloaded from Linux Kernel Archive
172       <https://www.kernel.org/pub/linux/utils/util-linux/>.
173
174
175
176util-linux 2.39.2                 2023-06-14                         PIPESZ(1)
Impressum