Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fork(2)

read(2V)

socketpair(2)

write(2V)

sh(1)

PIPE(2)  —  SYSTEM CALLS

NAME

pipe − create an interprocess communication channel

SYNOPSIS

pipe(fildes)
int fildes[2];

DESCRIPTION

The pipe() system call creates an I/O mechanism called a pipe and returns two file descriptors, fildes[0] and fildes[1]. fildes[0] is opened for reading and fildes[1] is opened for writing. When the pipe is written using the descriptor fildes[1] up to 4096 bytes of data are buffered before the writing process is blocked. A read only file descriptor fildes[0] accesses the data written to fildes[1] on a FIFO (first-in-first-out) basis. 

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 EOF (end of file). 

Pipes are really a special case of the socketpair(2) call and, in fact, are implemented as such in the system. 

A signal is generated if a write on a pipe with only one end is attempted. 

RETURN VALUE

The function value zero is returned if the pipe was created; −1 if an error occurred. 

ERRORS

The pipe() call will fail if:

EMFILE Too many descriptors are active. 

ENFILE The system file table is full. 

EFAULT The fildes file descriptor pair is in an invalid area of the process’s address space. 

SEE ALSO

fork(2), read(2V), socketpair(2), write(2V), sh(1)

BUGS

Should more than 4096 bytes be necessary in any pipe among a loop of processes, deadlock will occur. 

Sun Release 4.0  —  Last change: 22 March 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026