manual page distributed with 4.1BSD
[unix-history] / usr / src / lib / libc / sys / pipe.2
CommitLineData
c15b236d
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)pipe.2 4.1 (Berkeley) %G%
6.\"
7.TH PIPE 2
8.UC 4
9.SH NAME
10pipe \- create an interprocess channel
11.SH SYNOPSIS
12.nf
13.B pipe(fildes)
14.B int fildes[2];
15.fi
16.SH DESCRIPTION
17The
18.I pipe
19system call
20creates an I/O mechanism called a pipe.
21The file descriptors returned can
22be used in read and write operations.
23When the pipe is written using the descriptor
24.IR fildes [1]
25up to 4096 bytes of data are buffered
26before the writing process is suspended.
27A read using the descriptor
28.IR fildes [0]
29will pick up the data.
30.PP
31It is assumed that after the
32pipe has been set up,
33two (or more)
34cooperating processes
35(created by subsequent
36.I fork
37calls)
38will pass data through the
39pipe with
40.I read
41and
42.I write
43calls.
44.PP
45The Shell has a syntax
46to set up a linear array of processes
47connected by pipes.
48.PP
49Read calls on an empty
50pipe (no buffered data) with only one end
51(all write file descriptors closed)
52returns an end-of-file.
53.SH "SEE ALSO"
54sh(1), read(2), write(2), fork(2)
55.SH DIAGNOSTICS
56The function value zero is returned if the
57pipe was created; \-1 if
58too many files are already open.
59A signal is generated if a write on a pipe with only one end is attempted.
60.SH BUGS
61Should more than 4096 bytes be necessary in any
62pipe among a loop of processes, deadlock will occur.
63.SH "ASSEMBLER (PDP-11)"
64(pipe = 42.)
65.br
66.B sys pipe
67.br
68(read file descriptor in r0)
69.br
70(write file descriptor in r1)