pipe() creates a pipe and places two file descriptors, which refer to the open file descriptions for the read and write ends of the pipe, into the arguments fildes[0] and fildes[1] . These integer values are the two lowest available at the time of the pipe() call. The O_NONBLOCK bit is not set for either of the two file descriptors (the fcntl() function can be used to set the O_NONBLOCK bit).
Data can then be written to the file descriptor fildes[1] and read from file descriptor fildes[0] . A read on the file descriptor fildes[0] accesses the data written to file descriptor fildes[1] on a first-in-first-out basis. A process has the pipe open for reading if it has a file descriptor open that refers to the read end of the pipe, i.e. fildes[0] ; the same applies to writing and the write end, i.e. fildes[1] . Upon successful completion, pipe() will mark the stat structure components of the pipe, i.e. st_atime , st_ctime and st_mtime , for update. The FD_CLOEXEC bit is not set for either of the two file descriptors. |