pipe - create an interprocess channel
int pipe(int fildes);
pipe creates an I/O mechanism called a pipe and returns two file
descriptors, fildes<b> and fildes<b>. IRIX has two distinct versions of
pipe: the SVR4 version and the SVR3.2 version. The SVR3.2 version is
faster, and is generally preferred unless STREAMS semantics are required
for a specific reason.
The SVR4 version of pipe returns two STREAMS-based file descriptors which
are both opened for reading and writing. The O_NDELAY and O_NONBLOCK
flags are cleared. A read from fildes<b> accesses the data written to
fildes<b> on a first-in-first-out (FIFO) basis and a read from fildes<b>
accesses the data written to fildes<b> also on a FIFO basis. The
FD_CLOEXEC flag will be clear on both file descriptors.
The SVR3.2 version of pipe returns two non-STREAMS-based file
descriptors. Fildes is opened for reading and fildes is opened for
writing. Up to PIPE_BUF (defined in limits.h) bytes of data are buffered
by the pipe before the writing process is blocked and guaranteed to be
written atomically. The O_NDELAY and O_NONBLOCK flags are cleared. A
read only file descriptor fildes accesses the data written to
fildes on a first-in-first-out (FIFO) basis.
Upon successful completion pipe marks for update the st_atime, st_ctime,
and st_mtime fields of the pipe.
To use the SVR4 version of pipe one must normally tune the system tunable
variable svr3pipe to 0 (see systune(1M)). Otherwise, the SVR3.2 version
of pipe is used, with the exception of applications linked against
libnsl.so (-lnsl), which normally get SVR4-style pipes by default. This
can be disabled by setting the environment variable _LIBNSL_USE_SVR3_PIPE
to 1. In this case such applications will get SVR3.2-styl pipe
pipe fails if:
EMFILE The maximum number of file descriptors are currently open.
ENFILE A file table entry could not be allocated.
sh(1), systune(1M), fcntl(2), getmsg(2), intro(3N), poll(2), putmsg(2),
read(2), write(2), popen(3S), streamio(7)
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and errno is set to indicate the error.
Since a SVR4 version of 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<b> or fildes<b> is the number of bytes
available for reading from fildes<b> or fildes<b> respectively.
Previously, the size (st_size) returned by a call to fstat() with
argument fildes<b> (the write-end) was the number of bytes available for
reading from fildes<b> (the read-end).
PPPPaaaaggggeeee 2222 [ Back ]