PIPE(2) SysV PIPE(2)
NAME
pipe - create an interprocess channel
SYNOPSIS
int pipe (fildes)
int fildes[2];
DESCRIPTION
The pipe function creates a unidirectional interprocess channel called a
pipe, and returns two file descriptors, fildes[0] and fildes[1]. The file
descriptor specified by the fildes[0] argument is opened for reading and
the file descriptor specified by the fildes[1] argument is opened for
writing. Their integer values will be the two lowest available at the
time of the call to the pipe function. The O_NONBLOCK flag will be clear
on both file descriptors. (The fcntl function can be used to set the
O_NONBLOCK flag.)
Up to 5120 bytes of data are buffered by the pipe before the writing
process is blocked. A read-only file descriptor fildes[0] accesses the
data written to fildes[1] on a first-in-first-out (FIFO) basis.
A process has the pipe open for reading if it has a file descriptor open
that refers to the read end, fildes[0]. A process has the pipe open for
writing if it has a file descriptor open that refers to the write end,
fildes[1]. A read on file descriptor fildes[0] accesses the data written
to fildes[1] on a first-in, first-out (FIFO) basis.
Upon successful completion, the pipe function marks the st_atime,
st_ctime and st_mtime fields of the pipe for update.
The FD_CLOEXEC flag will be clear on both file descriptors.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and errno is set to indicate the error.
ERRORS
pipe will fail if any of the following is true:
[EMFILE] NOFILES file descriptors are currently open.
[ENFILE] The system file table is full.
SEE ALSO
read(2), write(2).
sh(1) in the SysV Command Reference.