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