]> git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/pipesz.1.adoc
flock: initialize timevals [-Werror=maybe-uninitialized]
[thirdparty/util-linux.git] / misc-utils / pipesz.1.adoc
1 //po4a: entry man manual
2 = pipesz(1)
3 :doctype: manpage
4 :man manual: User Commands
5 :man source: util-linux {release-version}
6 :page-layout: base
7 :command: pipesz
8
9 == NAME
10
11 pipesz - set or examine pipe and FIFO buffer sizes
12
13 == SYNOPSIS
14
15 *pipesz* [options] [--set _size_] [--] [_command_ [argument] ...]
16
17 *pipesz* [options] --get
18
19 == DESCRIPTION
20
21 Pipes and FIFOs maintain an internal buffer used to transfer data between the read end and the write end. In some cases, the default size of this internal buffer may not be appropriate. This program provides facilities to set and examine the size of these buffers.
22
23 The *--set* operation sets pipe buffer sizes. If it is specified, it must be specified with an explicit _size_. Otherwise, it is implied and the size is read from */proc/sys/fs/pipe-max-size*. The kernel may adjust _size_ as described in *fcntl*(2). To determine the actual buffer sizes set, use the *--verbose* option. If neither *--file* nor *--fd* are specified, *--set* acts on standard output.
24
25 The *--set* operation permits an optional _command_ to execute after setting the pipe buffer sizes. This command is executed with the adjusted pipes.
26
27 The *--get* operation outputs data in a tabular format. The first column is the name of the pipe as passed to *pipesz*. File descriptors are named as "fd _N_". The second column is the size, in bytes, of the pipe's internal buffer. The third column is the number of unread bytes currently in the pipe. The columns are separated by tabs ('\t', ASCII 09h). If *--verbose* is specified, a descriptive header is also emitted. If neither *--file* nor *--fd* are specified, *--get* acts on standard input.
28
29 Unless the *--check* option is specified, *pipesz* does _not_ exit if it encounters an error while manipulating a file or file descriptor. This allows *pipesz* to be used generically without fear of disrupting the execution of pipelines should the type of certain files be later changed. For minimal disruption, the *--quiet* option prevents warnings from being emitted in these cases.
30
31 The kernel imposes limits on the amount of pipe buffer space unprivileged processes can use, though see *BUGS* below. The kernel will also refuse to shrink a pipe buffer if this would cause a loss of buffered data. See *pipe*(7) for additional details.
32
33 *pipesz* supports specifying multiple short options consecutively, in the usual *getopt*(3) fashion. The first non-option argument is interpreted as _command_. If _command_ might begin with '-', use '--' to separate it from arguments to *pipesz*. In shell scripts, it is good practice to use '--' when parameter expansion is involved. *pipesz* itself does not read from standard input and does not write to standard output unless *--get*, *--help*, or *--version* are specified.
34
35 == OPTIONS
36
37 *-g*, *--get*::
38 Report the size of pipe buffers to standard output and exit. As a special behavior, if neither *--file* nor *--fd* are specified, standard input is examined. It is an error to specify this option in combination with *--set*.
39
40 *-s*, *--set* _size_::
41 Set the size of the pipe buffers, in bytes. This option may be suffixed by _K_, _M_, _G_, _KiB_, _MiB_, or _GiB_ to indicate multiples of 1024. Fractional values are supported in this case. Additional suffixes are supported but are unlikely to be useful. If this option is not specified, a default value is used, as described above. If this option is specified multiple times, a warning is emitted and only the last-specified _size_ is used. As a special behavior, if neither *--file* nor *--fd* are specified, standard output is adjusted. It is an error to specify this option in combination with *--get*.
42
43 *-f*, *--file* _path_::
44 Set the buffer size of the FIFO or pipe at _path_, relative to the current working directory. You may specify this option multiple times to affect different files, and you may do so in combination with *--fd*. Generally, this option is used with FIFOs, but it will also operate on anonymous pipes such as those found in */proc/PID/fd*. Changes to the buffer size of FIFOs are not preserved across system restarts.
45
46 *-n*, *--fd* _fd_::
47 Set the buffer size of the pipe or FIFO passed to *pipesz* as the specified file descriptor number. You may specify this option multiple times to affect different file descriptors, and you may do so in combination with *--file*. Shorthand options are provided for the common cases of fd 0 (stdin), fd 1 (stdout), and fd 2 (stderr). These should suffice in most cases.
48
49 *-i*, *--stdin*::
50 Shorthand for *--fd 0*.
51
52 *-o*, *--stdout*::
53 Shorthand for *--fd 1*.
54
55 *-e*, *--stderr*::
56 Shorthand for *--fd 2*.
57
58 *-c*, *--check*::
59 Exit, without executing _command_, in case of any error while manipulating a file or file descriptor. The default behavior if this is not specified is to emit a warning to standard error and continue.
60
61 *-q*, *--quiet*::
62 Do not diagnose non-fatal errors to standard error. This option does not affect the normal output of *--get*, *--verbose*, *--help*, or *--version*.
63
64 *-v*, *--verbose*::
65 If specified with *--get*, *pipesz* will emit a descriptive header above the table. Otherwise, if specified, *pipesz* will print the actual buffer sizes set by the kernel to standard error.
66
67 include::man-common/help-version.adoc[]
68
69 == EXAMPLES
70
71 *pipesz* *dd* if=_file_ bs=1M | ...::
72 Runs *dd*(1) with an expanded standard output pipe, allowing it to avoid context switches when piping around large blocks.
73
74 *pipesz* -s1M -cf _/run/my-service.fifo_::
75 Sets the pipe buffer size of a service FIFO to 1,048,576 bytes. If the buffer size could not be set, *pipesz* exits with an error.
76
77 *echo* hello | *pipesz* -g::
78 Prints the size of pipe used by the shell to pass input to *pipesz*. Since *pipesz* does not read standard input, it may also report 6 unread bytes in the pipe, depending on relative timings.
79
80 *find* /proc/_PID_/fd -exec *pipesz* -gqf '{}' ';'::
81 Prints the size and number of unread bytes of all pipes in use by _PID_. If some pipes are routinely full, *pipesz* might be able to mitigate a processing bottleneck.
82
83 == NOTES
84
85 Linux supports adjusting the size of pipe buffers since kernel 2.6.35. This release also introduced */proc/sys/fs/pipe-max-size*.
86
87 This program uses *fcntl*(2) *F_GETPIPE_SZ*/*F_SETPIPE_SZ* to get and set pipe buffer sizes.
88
89 This program uses *ioctl*(2) *FIONREAD* to report the amount of unread data in pipes. If for some reason this fails, the amount of unread data is reported as 0.
90
91 == BUGS
92
93 Before Linux 4.9, some bugs affect how certain resource limits are enforced when setting pipe buffer sizes. See *pipe*(7) for details.
94
95 == AUTHORS
96
97 mailto:nwsharp@live.com[Nathan Sharp]
98
99 == SEE ALSO
100
101 *pipe*(7)
102
103 include::man-common/bugreports.adoc[]
104
105 include::man-common/footer.adoc[]
106
107 ifdef::translation[]
108 include::man-common/translation.adoc[]
109 endif::[]