1PIPE(2) System Calls Manual PIPE(2)
2
3
4
6 pipe - create an interprocess communication channel
7
9 pipe(fildes)
10 int fildes[2];
11
13 The pipe system call creates an I/O mechanism called a pipe. The file
14 descriptors returned can be used in read and write operations. When
15 the pipe is written using the descriptor fildes[1] up to 4096 bytes of
16 data are buffered before the writing process is suspended. A read
17 using the descriptor fildes[0] will pick up the data.
18
19 It is assumed that after the pipe has been set up, two (or more) coop‐
20 erating processes (created by subsequent fork calls) will pass data
21 through the pipe with read and write calls.
22
23 The shell has a syntax to set up a linear array of processes connected
24 by pipes.
25
26 Read calls on an empty pipe (no buffered data) with only one end (all
27 write file descriptors closed) returns an end-of-file.
28
29 Pipes are really a special case of the socketpair(2) call and, in fact,
30 are implemented as such in the system.
31
32 A signal is generated if a write on a pipe with only one end is
33 attempted.
34
36 The function value zero is returned if the pipe was created; -1 if an
37 error occurred.
38
40 The pipe call will fail if:
41
42 [EMFILE] Too many descriptors are active.
43
44 [ENFILE] The system file table is full.
45
46 [EFAULT] The fildes buffer is in an invalid area of the process's
47 address space.
48
50 sh(1), read(2), write(2), fork(2), socketpair(2)
51
53 Should more than 4096 bytes be necessary in any pipe among a loop of
54 processes, deadlock will occur.
55
56
57
584th Berkeley Distribution August 26, 1985 PIPE(2)