Commit | Line | Data |
---|---|---|
88d0a458 KT |
1 | .th PIPE II 8/5/73 |
2 | .sh NAME | |
3 | pipe \*- create a pipe | |
4 | .sh SYNOPSIS | |
5 | (pipe = 42.) | |
6 | .br | |
7 | .ft B | |
8 | sys pipe | |
9 | .br | |
10 | .ft R | |
11 | (read file descriptor in r0) | |
12 | .br | |
13 | (write file descriptor in r1) | |
14 | .s3 | |
15 | .ft B | |
16 | pipe(fildes) | |
17 | .br | |
18 | int fildes[2]; | |
19 | .ft R | |
20 | .sh DESCRIPTION | |
21 | The | |
22 | .it pipe | |
23 | system call | |
24 | creates an I/O mechanism called a pipe. | |
25 | The file descriptors returned can | |
26 | be used in read and write operations. | |
27 | When the pipe is written using the descriptor | |
28 | returned in r1 (resp. fildes[1]), | |
29 | up to 4096 bytes of data are buffered | |
30 | before the writing process is suspended. | |
31 | A read using the descriptor returned in r0 | |
32 | (resp. fildes[0]) | |
33 | will pick up the data. | |
34 | .s3 | |
35 | It is assumed that after the | |
36 | pipe has been set up, | |
37 | two (or more) | |
38 | cooperating processes | |
39 | (created by subsequent | |
40 | .it fork | |
41 | calls) | |
42 | will pass data through the | |
43 | pipe with | |
44 | .it read | |
45 | and | |
46 | .it write | |
47 | calls. | |
48 | .s3 | |
49 | The shell has a syntax | |
50 | to set up a linear array of processes | |
51 | connected by pipes. | |
52 | .s3 | |
53 | Read calls on an empty | |
54 | pipe (no buffered data) with only one end | |
55 | (all write file descriptors closed) | |
56 | return an end-of-file. | |
57 | Write calls under similar conditions are ignored. | |
58 | .sh "SEE ALSO" | |
59 | sh(I), read(II), write(II), fork(II) | |
60 | .sh DIAGNOSTICS | |
61 | The error | |
62 | bit (c-bit) is set if | |
63 | more than | |
64 | 8 files are already open. | |
65 | From C, a \*-1 returned value | |
66 | indicates an error. |