add -s option which inserts/matches truncated member names
[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.\"
dc138177 5.\" @(#)pipe.2 6.3 (Berkeley) %G%
c15b236d 6.\"
7a1972f0 7.TH PIPE 2 ""
c15b236d
KM
8.UC 4
9.SH NAME
0bbf2c7d 10pipe \- create an interprocess communication channel
c15b236d
KM
11.SH SYNOPSIS
12.nf
0bbf2c7d
KM
13.ft B
14pipe(fildes)
15int fildes[2];
c15b236d 16.fi
0bbf2c7d 17.ft R
c15b236d
KM
18.SH DESCRIPTION
19The
20.I pipe
21system call
22creates an I/O mechanism called a pipe.
23The file descriptors returned can
24be used in read and write operations.
25When the pipe is written using the descriptor
26.IR fildes [1]
27up to 4096 bytes of data are buffered
28before the writing process is suspended.
29A read using the descriptor
30.IR fildes [0]
31will pick up the data.
32.PP
33It is assumed that after the
34pipe has been set up,
35two (or more)
36cooperating processes
37(created by subsequent
38.I fork
39calls)
40will pass data through the
41pipe with
42.I read
43and
44.I write
45calls.
46.PP
0bbf2c7d 47The shell has a syntax
c15b236d
KM
48to set up a linear array of processes
49connected by pipes.
50.PP
51Read calls on an empty
52pipe (no buffered data) with only one end
53(all write file descriptors closed)
54returns an end-of-file.
0bbf2c7d
KM
55.PP
56Pipes are really a special case of the
57.IR socketpair (2)
58call and, in fact, are implemented as such in the system.
59.PP
c15b236d 60A signal is generated if a write on a pipe with only one end is attempted.
0bbf2c7d
KM
61.SH "RETURN VALUE
62The function value zero is returned if the
63pipe was created; \-1 if an error occurred.
64.SH ERRORS
65The \fIpipe\fP call will fail if:
66.TP 15
67[EMFILE]
68Too many descriptors are active.
69.TP 15
fd690c8b
KM
70[ENFILE]
71The system file table is full.
72.TP 15
0bbf2c7d
KM
73[EFAULT]
74The \fIfildes\fP buffer is in an invalid area of the process's address
75space.
76.SH "SEE ALSO"
77sh(1), read(2), write(2), fork(2), socketpair(2)
c15b236d
KM
78.SH BUGS
79Should more than 4096 bytes be necessary in any
80pipe among a loop of processes, deadlock will occur.