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