pipe - create an interprocess channel
int pipe(int fildes);
The pipe() function creates an I/O mechanism called a pipe
and returns two file descriptors, fildes and fildes.
The files associated with fildes and fildes are
streams and are both opened for reading and writing.
The O_NDELAY and O_NONBLOCK flags are cleared.
A read from fildes accesses the data written to fildes
on a first-in-first-out (FIFO) basis and a read from
fildes accesses the data written to fildes also on a
The FD_CLOEXEC flag will be clear on both file descriptors.
Upon successful completion pipe() marks for update the
st_atime, st_ctime, and st_mtime fields of the pipe.
Upon successful completion, 0 is returned. Otherwise, -1 is
returned and errno is set to indicate the error.
The pipe() function will fail if:
There are OPEN_MAX-1 or more file descriptors
currently open for this process.
A file table entry could not be allocated.
See attributes(5) for descriptions of the following attri-
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
| MT-Level | Async-Signal-Safe |
sh(1), fcntl(2), fstat(2), getmsg(2), poll(2), putmsg(2),
read(2), write(2), attributes(5), streamio(7I)
Since a pipe is bi-directional, there are two separate flows
of data. Therefore, the size (st_size) returned by a call to
fstat(2) with argument fildes or fildes is the number
of bytes available for reading from fildes or fildes
respectively. Previously, the size (st_size) returned by a
call to fstat() with argument fildes (the write-end) was
the number of bytes available for reading from fildes
Man(1) output converted with