pipe(2) pipe(2) NAME pipe - create an interprocess channel C SYNOPSIS #include <unistd.h> int pipe(int fildes[2]); DESCRIPTION pipe creates an I/O mechanism called a pipe and returns two file descriptors, fildes[0] and fildes[1]. 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[0] accesses the data written to fildes[1] on a first-in-first-out (FIFO) basis and a read from fildes[1] accesses the data written to fildes[0] 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[0] is opened for reading and fildes[1] 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[0] accesses the data written to fildes[1] 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 semantics. pipe fails if: EMFILE The maximum number of file descriptors are currently open. ENFILE A file table entry could not be allocated. SEE ALSO sh(1), systune(1M), fcntl(2), getmsg(2), intro(3N), poll(2), putmsg(2), read(2), write(2), popen(3S), streamio(7) 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. NOTES 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[0] or fildes[1] is the number of bytes available for reading from fildes[0] or fildes[1] respectively. Previously, the size (st_size) returned by a call to fstat() with argument fildes[1] (the write-end) was the number of bytes available for reading from fildes[0] (the read-end). Page 2