pipe(2)
NAME
pipe − create an interprocess channel
SYNTAX
int pipe(fildes)
int fildes[2];
DESCRIPTION
The pipe system call 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 fildes[1] descriptor, up to a maximum 4096 bytes of data are buffered before the writing process is blocked. A read using the fildes[0] descriptor will pick up the data.
It is assumed that after the pipe has been set up, two or more cooperating processes (created by subsequent fork calls) will pass data through the pipe with read and write calls.
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. A signal is generated if a write on a pipe with only one end is attempted.
RESTRICTIONS
Should more than 4096 bytes be necessary in any pipe among a loop of processes, deadlock will occur.
DIAGNOSTICS
The pipe call will fail if:
[EFAULT] The fildes argument is in an invalid area of the process’s allocated address space.
[EMFILE] Too many file descriptors (more than 19) are active.
[ENFILE] No more system file descriptors are available.
[ENFILE] There is insufficient system space to contain the inode.
[ENOSPC] No more inodes are available on the device.
ASSEMBLER
(pipe = 42.)
sys pipe
(read file descriptor in r0)
(write file descriptor in r1)