summaryrefslogtreecommitdiffstats
path: root/man7/pipe.7
diff options
context:
space:
mode:
Diffstat (limited to 'man7/pipe.7')
-rw-r--r--man7/pipe.794
1 files changed, 47 insertions, 47 deletions
diff --git a/man7/pipe.7 b/man7/pipe.7
index d1fad9974..4076ae27e 100644
--- a/man7/pipe.7
+++ b/man7/pipe.7
@@ -16,20 +16,20 @@ Data written to the write end of a pipe can be read
from the read end of the pipe.
.P
A pipe is created using
-.BR pipe (2),
+.MR pipe 2 ,
which creates a new pipe and returns two file descriptors,
one referring to the read end of the pipe,
the other referring to the write end.
Pipes can be used to create a communication channel between related
processes; see
-.BR pipe (2)
+.MR pipe 2
for an example.
.P
A FIFO (short for First In First Out) has a name within the filesystem
(created using
-.BR mkfifo (3)),
+.MR mkfifo 3 ),
and is opened using
-.BR open (2).
+.MR open 2 .
Any process may open a FIFO, assuming the file permissions allow it.
The read end is opened using the
.B O_RDONLY
@@ -37,7 +37,7 @@ flag; the write end is opened using the
.B O_WRONLY
flag.
See
-.BR fifo (7)
+.MR fifo 7
for further details.
.IR Note :
although FIFOs have a pathname in the filesystem,
@@ -50,20 +50,20 @@ Once these tasks have been accomplished,
I/O on pipes and FIFOs has exactly the same semantics.
.P
If a process attempts to read from an empty pipe, then
-.BR read (2)
+.MR read 2
will block until data is available.
If a process attempts to write to a full pipe (see below), then
-.BR write (2)
+.MR write 2
blocks until sufficient data has been read from the pipe
to allow the write to complete.
.P
Nonblocking I/O is possible by using the
-.BR fcntl (2)
+.MR fcntl 2
.B F_SETFL
operation to enable the
.B O_NONBLOCK
open file status flag or by opening a
-.BR fifo (7)
+.MR fifo 7
with
.BR O_NONBLOCK .
If any process has the pipe open for writing, reads fail with
@@ -76,38 +76,38 @@ there is no concept of message boundaries.
.P
If all file descriptors referring to the write end of a pipe
have been closed, then an attempt to
-.BR read (2)
+.MR read 2
from the pipe will see end-of-file
.RB ( read (2)
will return 0).
If all file descriptors referring to the read end of a pipe
have been closed, then a
-.BR write (2)
+.MR write 2
will cause a
.B SIGPIPE
signal to be generated for the calling process.
If the calling process is ignoring this signal, then
-.BR write (2)
+.MR write 2
fails with the error
.BR EPIPE .
An application that uses
-.BR pipe (2)
+.MR pipe 2
and
-.BR fork (2)
+.MR fork 2
should use suitable
-.BR close (2)
+.MR close 2
calls to close unnecessary duplicate file descriptors;
this ensures that end-of-file and
.BR SIGPIPE / EPIPE
are delivered when appropriate.
.P
It is not possible to apply
-.BR lseek (2)
+.MR lseek 2
to a pipe.
.SS Pipe capacity
A pipe has a limited capacity.
If the pipe is full, then a
-.BR write (2)
+.MR write 2
will block or fail, depending on whether the
.B O_NONBLOCK
flag is set (see below).
@@ -123,17 +123,17 @@ Since Linux 2.6.11, the pipe capacity is 16 pages
(i.e., 65,536 bytes in a system with a page size of 4096 bytes).
Since Linux 2.6.35, the default pipe capacity is 16 pages,
but the capacity can be queried and set using the
-.BR fcntl (2)
+.MR fcntl 2
.B F_GETPIPE_SZ
and
.B F_SETPIPE_SZ
operations.
See
-.BR fcntl (2)
+.MR fcntl 2
for more information.
.P
The following
-.BR ioctl (2)
+.MR ioctl 2
operation, which can be applied to a file descriptor
that refers to either end of a pipe,
places a count of the number of unread bytes in the pipe in the
@@ -184,7 +184,7 @@ display the contents of this file after assigning a value to it.
The default value for this file is 1048576 (1\ MiB).
The minimum value that can be assigned to this file is the system page size.
Attempts to set a limit less than the page size cause
-.BR write (2)
+.MR write 2
to fail with the error
.BR EINVAL .
.IP
@@ -259,7 +259,7 @@ the number of bytes to be written:
All
.I n
bytes are written atomically;
-.BR write (2)
+.MR write 2
may block if there is not room for
.I n
bytes to be written immediately
@@ -268,11 +268,11 @@ bytes to be written immediately
If there is room to write
.I n
bytes to the pipe, then
-.BR write (2)
+.MR write 2
succeeds immediately, writing all
.I n
bytes; otherwise
-.BR write (2)
+.MR write 2
fails, with
.I errno
set to
@@ -280,19 +280,19 @@ set to
.TP
\fBO_NONBLOCK\fP disabled, \fIn\fP > \fBPIPE_BUF\fP
The write is nonatomic: the data given to
-.BR write (2)
+.MR write 2
may be interleaved with
-.BR write (2)s
+.MR write 2 s
by other process;
the
-.BR write (2)
+.MR write 2
blocks until
.I n
bytes have been written.
.TP
\fBO_NONBLOCK\fP enabled, \fIn\fP > \fBPIPE_BUF\fP
If the pipe is full, then
-.BR write (2)
+.MR write 2
fails, with
.I errno
set to
@@ -301,7 +301,7 @@ Otherwise, from 1 to
.I n
bytes may be written (i.e., a "partial write" may occur;
the caller should check the return value from
-.BR write (2)
+.MR write 2
to see how many bytes were actually written),
and these bytes may be interleaved with writes by other processes.
.SS Open file status flags
@@ -317,7 +317,7 @@ flag for the read end of a pipe causes a signal
.RB ( SIGIO
by default) to be generated when new input becomes available on the pipe.
The target for delivery of signals must be set using the
-.BR fcntl (2)
+.MR fcntl 2
.B F_SETOWN
command.
On Linux,
@@ -335,7 +335,7 @@ Before Linux 4.9, some bugs affected the handling of the
and
.I pipe\-user\-pages\-hard
limits when using the
-.BR fcntl (2)
+.MR fcntl 2
.B F_SETPIPE_SZ
operation to change a pipe's capacity:
.\" These bugs where remedied by a series of patches, in particular,
@@ -387,21 +387,21 @@ and the operation fails if the limit would be exceeded.
Before Linux 4.9, bugs similar to points (a) and (c) could also occur
when the kernel allocated memory for a new pipe buffer;
that is, when calling
-.BR pipe (2)
+.MR pipe 2
and when opening a previously unopened FIFO.
.SH SEE ALSO
-.BR mkfifo (1),
-.BR dup (2),
-.BR fcntl (2),
-.BR open (2),
-.BR pipe (2),
-.BR poll (2),
-.BR select (2),
-.BR socketpair (2),
-.BR splice (2),
-.BR stat (2),
-.BR tee (2),
-.BR vmsplice (2),
-.BR mkfifo (3),
-.BR epoll (7),
-.BR fifo (7)
+.MR mkfifo 1 ,
+.MR dup 2 ,
+.MR fcntl 2 ,
+.MR open 2 ,
+.MR pipe 2 ,
+.MR poll 2 ,
+.MR select 2 ,
+.MR socketpair 2 ,
+.MR splice 2 ,
+.MR stat 2 ,
+.MR tee 2 ,
+.MR vmsplice 2 ,
+.MR mkfifo 3 ,
+.MR epoll 7 ,
+.MR fifo 7