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