Manual page for PIPE(2)
pipe - create an interprocess communication channel
int pipe(int fildes)
creates an I/O mechanism called a pipe.
The file descriptors returned can
be used in read and write operations.
When the pipe is written using the descriptor
up to 4096 bytes of data
(PIPE_BUF bytes for POSIX applications;
are buffered before the writing process is suspended.
A read using the descriptor
will pick up the data.
It is assumed that after the
pipe has been set up,
two (or more)
(created by subsequent
will pass data through the
The shell has a syntax
to set up a linear array of processes
connected by pipes.
Read calls on an empty
pipe (no buffered data) with only one end
(all write file descriptors closed)
returns an end-of-file.
Pipes are really a special case of the
call and, in fact, are implemented as such in the system.
Upon successful completion, the pipe function will update the
st_atime, st_ctime, and st_mtime fields of the pipe.
A signal is generated if a write on a pipe with only one end is attempted.
The function value zero is returned if the
pipe was created; -1 if an error occurred.
The pipe call will fail if:
Too many descriptors are active.
The system file table is full.
The fildes buffer is in an invalid area of the process's address
sh(1), read(2), write(2), fork(2), socketpair(2), stat(2) or stat(2P)
Should more than 4096 (PIPE_BUF for POSIX) bytes be necessary in any
pipe among a loop of processes, deadlock will occur.
Created by unroff & hp-tools.
© by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 21/April/97