version 2, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
FIFO |
|
|
2 |
!!!FIFO |
|
|
3 |
NAME |
|
|
4 |
DESCRIPTION |
|
|
5 |
NOTES |
|
|
6 |
SEE ALSO |
|
|
7 |
---- |
|
|
8 |
!!NAME |
|
|
9 |
|
|
|
10 |
|
|
|
11 |
fifo - first-in first-out special file, named pipe |
|
|
12 |
!!DESCRIPTION |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
A FIFO special file (a named pipe) is similar to a pipe, |
|
|
16 |
except that it is accessed as part of the file system. It |
|
|
17 |
can be opened by multiple processes for reading or writing. |
|
|
18 |
When processes are exchanging data via the FIFO, the kernel |
|
|
19 |
passes all data internally without writing it to the file |
|
|
20 |
system. Thus, the FIFO special file has no contents on the |
|
|
21 |
file system, the file system entry merely serves as a |
|
|
22 |
reference point so that processes can access the pipe using |
|
|
23 |
a name in the file system. |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
The kernel maintains exactly one pipe object for each FIFO |
|
|
27 |
special file that is opened by at least one process. The |
|
|
28 |
FIFO must be opened on both ends (reading and writing) |
|
|
29 |
before data can be passed. Normally, opening the FIFO blocks |
|
|
30 |
until the other end is opened also. |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
A process can open a FIFO in non-blocking mode. In this |
|
|
34 |
case, opening for read only will succeed even if noone has |
|
|
35 |
opened on the write side yet; opening for write only will |
|
|
36 |
fail with ENXIO (no such device or address) unless the other |
|
|
37 |
end has already been opened. |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
Under Linux, opening a FIFO for read and write will succeed |
|
|
41 |
both in blocking and non-blocking mode. POSIX leaves this |
|
|
42 |
behaviour undefined. This can be used to open a FIFO for |
|
|
43 |
writing while there are no readers available. A process that |
|
|
44 |
uses both ends of the connection in order to communicate |
|
|
45 |
with itself should be very careful to avoid |
|
|
46 |
deadlocks. |
|
|
47 |
!!NOTES |
|
|
48 |
|
|
|
49 |
|
2 |
JohnDoe |
50 |
When a process tries to write to a FIFO that is not opened anymore |
1 |
perry |
51 |
for read on the other side, the process is sent a SIGPIPE |
|
|
52 |
signal. |
|
|
53 |
|
2 |
JohnDoe |
54 |
In general, if you close and re-open one side you need to do it on the other side, too. ''(Is this correct?)'' |
1 |
perry |
55 |
|
|
|
56 |
FIFO special files can be created by mkfifo(3), and |
|
|
57 |
are specially indicated in ''ls -l''. |
|
|
58 |
!!SEE ALSO |
|
|
59 |
|
|
|
60 |
|
|
|
61 |
mkfifo(3), mkfifo(1), pipe(2), |
|
|
62 |
socketpair(2), open(2), signal(2), |
|
|
63 |
sigaction(2) |
|
|
64 |
---- |