PIPE(2) COMMAND REFERENCE PIPE(2) NAME pipe - create an interprocess communication channel SYNOPSIS pipe(fd) int fd[2]; DESCRIPTION The pipe system call creates an I/O mechanism called a pipe. Then executed, the command returns two file descriptors in fd[]; fd[0] is opened for reading, and fd[1] is opened for writing. When the pipe is written using fd[1] up to MINBSIZE (defined in <sys/fs.h>) bytes of data are buffered before the writing process is blocked. A read using fd[0] picks up the data. It is assumed that after the pipe has been set up, two (or more) cooperating processes (created by subsequent fork(2) calls) pass data through the pipe with read(2) and write(2) calls. The shell has a syntax to set up a linear array of processes connected by pipes. See sh(1SH). Calls from read call on an empty pipe (no buffered data) with only one end (all write file descriptors closed) return an end-of-file. The pipe system call is really a special case of the socketpair(2) call and, in fact, is implemented as such in the system. A signal (SIGPIPE) is generated if a write on a pipe with only one end is attempted. DIAGNOSTICS The pipe call fails if: [EMFILE] More than NOFILE - 2 (defined in <sys/max.h>) descriptors are already open in this process. [EFAULT] The fd buffer is in an invalid area of the process's address space. [ENFILE] The system file table is full. [ENOBUF] No buffer space is available for the pipe. RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. Printed 5/12/88 1
PIPE(2) COMMAND REFERENCE PIPE(2) CAVEATS Should more than 4096 bytes be necessary in any pipe among a loop of processes, deadlock occurs. SEE ALSO fork(2), read(2), sh(1sh), socketpair(2), and write(2). Printed 5/12/88 2
%%index%% na:240,103; sy:343,290; de:633,1660; di:2293,596; rv:2889,279; ca:3480,226; se:3706,250; %%index%%000000000122