#include <unistd.h> int pipe(int fildes); int pipe2(int fildes, int flags);
The pipe() and pipe2() functions create 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 pipe() call will clear the O_NDELAY, O_NONBLOCK, and FD_CLOEXEC flags on both file descriptors. The fcntl(2) function can be used to set these flags.
The pipe2() call will clear the O_NDELAY on both filedescriptors. The flags argument may be used to specify attributes on both file descriptors. pipe2() called with a flags value of 0 will behave identically to pipe(). Values for flags are constructed by a bitwise-inclusive-OR of flags from the following list, defined in <fcntl.h>.
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 FIFO basis.
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() and pipe2() functions will fail if:
The pipe2() function will also fail if:
See attributes(7) for descriptions of the following attributes:
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
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 (the read-end).
|April 19, 2013||OmniOS|