1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) 2005 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Japanese Version Copyright (c) 2005 Akihiro MOTOKI all rights reserved.
.\" Translated 2005-12-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.TH PIPE 7 2005-12-08 "Linux" "Linux Programmer's Manual"
.SH ̾
pipe \- ѥפ FIFO γ
.SH
ѥפ FIFO (̾դѥפȤ⤤) ϡ
ñΥץ̿ͥ롣
ѥפˤϡɤ߽Ф¦פȡֽ¦פ롣
ѥפν¦ǽޤ줿ǡϡ
ѥפɤ߽Ф¦ɤ߽ФȤǤ롣
ѥפˤ
.BR pipe (2)
Ѥ롣
.BR pipe (2)
Ͽѥפե롦ǥץ֤
ǥץΤϥѥפɤ߽Ф¦⤦
¦ȤƤ롣
ѥפϴϢץ֤̿Τ˻ѤǤ롣
.BR pipe (2)
ȡ
FIFO (First In First Out ξά) ϥե륷ƥǤ̾
.BR open (2)
ȤäƥץǤ
.RB ( mkfifo (3)
Ȥäƺ)
ɤʥץǤ⡢եΥĤ FIFO ץ
ȤǤ롣
ɤ߽Ф¦ץˤ
.B O_RDONLY
ե饰Ѥ¦ץˤ
.B O_WRONLY
ե饰Ѥ롣ܺ٤
.BR fifo (7)
ȡ
ա
FIFO ϥե륷ƥΥѥ̾Ĥ
FIFO ФϤԤäƤ⡢(ե륷ƥब¸ߤǥХ
äȤƤ) ΥǥХФȯʤ
.SS "ѥפ FIFO Ф"
ѥפ FIFO ΰ㤤Ϻ䥪ץˡǤ롣
λϡѥפ FIFO ФϤ
ƱȤߤǹԤ롣
ץΥѥפɤ߽ФԤȤ硢
.BR read (2)
ϥǡɤ߽Фǽˤʤޤߤ롣
ץե֤Υѥפ˽ߤԤȤ硢
.BR write (2)
ϽߤλΤ˽ʬ̤Υѥפɤ߽Ф
Ԥޤߤ롣
(non-blocking) I/O ȤȤǤ롣
I/O Ȥˤϡ
.BR fcntl (2)
.B F_SETFL
Ȥäơ
.B O_NONBLOCK
ץե֥ե饰ͭˤ롣
ѥפˤ̿ͥϡ֥ХȥȥפǤꡢ
åγǰϤʤ
ѥפν¦ȤƤե롦ǥץ
٤ƥ줿ǡΥѥפ
.BR read (2)
ԤȤ硢
end-of-file (ե)
.RB ( read (2)
0 ֤)
ѥפɤ߽Ф¦ȤƤե롦ǥץ
٤ƥ줿ǡ
.BR write (2)
ԤȡƤӽФץ
.B SIGPIPE
ʥ뤬롣
ƤӽФץΥʥ̵뤷ƤȤˤϡ
.BR write (2)
ϥ顼
.B EPIPE
ǼԤ롣
.BR pipe (2)
.BR fork (2)
Ѥ륢ץꥱǤϡ
.BR close (2)
Ŭڤ˻Ȥäɬפʥե롦ǥץʣ
٤Ǥ롣뤳Ȥǡɬפʻ˳μ¤
end-of-file
.BR SIGPIPE / EPIPE
褦ˤʤ롣
ѥפˤ
.BR lseek (2)
ԤȤϤǤʤ
.SS ѥפ
ѥפ̤ˤϾ¤롣
ѥפեξ硢
.BR write (2)
ߤ꼺Ԥꤹ롣ɤˤʤ뤫
.B O_NONBLOCK
ե饰åȤƤ뤫ɤ˰¸ ()
ˤꡢѥפ̤ξ¤ϰۤʤ롣
ץꥱ̤ˤ٤ǤϤʤ
¦Υץߤޤޤˤʤʤ褦
ɤ߽Ф¦ΥץϥǡѲǽˤʤäǤ
ɤ߽ФԤ褦ˡץꥱ߷פ٤Ǥ롣
С 2.6.11 Linux Ǥϥѥפ̤ϥƥΥڡ
ƱǤä (㤨 i386 Ǥ 4096 Х)
Linux 2.6.11 ʹߤǤϡѥפ̤ 65536 ХȤǤ롣
.SS PIPE_BUF
POSIX.1-2001 Ǥϡ
.B PIPE_BUF
ХȰʲ
.BR write (2)
atomic ˹Ԥ뤳ȡĤޤѥפؤνϥǡνߤ
Ϣ³ȤƹԤ뤳ȤɬܤȤƤ (MUST)
.B PIPE_BUF
ХȤ¿Υǡ߾ atomic ȤϤʤʤ
Ĥޤѥפؤ¾Υץˤǡνߤ֤
ǽ롣
POSIX.1-2001 λͤǤϡ
.B PIPE_BUF
ϺǾǤ 512 ХȤǤ뤳ȤᤵƤ
(Linux Ǥ
.B PIPE_BUF
4096 ХȤǤ)
Τưϡե롦ǥץ non-blocking
.RB ( O_NONBLOCK )
ɤѥפؤνߤʣԤ뤫ɤ
ߤԤХȿ
.I n
ˤꤵ롣
.TP
\fBO_NONBLOCK\fP ̵, \fIn\fP <= \fBPIPE_BUF\fP
.I n
Хνߤ atomic ˹Ԥ롣
.I n
Хʬ˽;Ϥʤ
.BR write (2)
(block) 뤳Ȥ롣
.TP
\fBO_NONBLOCK\fP ͭ, \fIn\fP <= \fBPIPE_BUF\fP
ѥפ
.I n
ХȤ;Ϥϡ
.I n
Х˽ޤ롣
;Ϥʤϡ
.BR write (2)
ϼԤ
.I errno
.B EAGAIN
åȤ롣
.TP
\fBO_NONBLOCK\fP ̵, \fIn\fP > \fBPIPE_BUF\fP
ߤ atomic ȤϤʤʤ
.BR write (2)
Ϥ줿ǡδ֤ˡ¾Υץˤ
.BR write (2)
줿ǡ뤳Ȥ롣
.BR write (2)
.I n
ХȤνߤλޤߤ롣
.TP
\fBO_NONBLOCK\fP ͭ, \fIn\fP > \fBPIPE_BUF\fP
ѥפեξ硢
.BR write (2)
ϼԤ
.I errno
.B EAGAIN
åȤ롣
ʳξ硢1 ХȰʾ
.I n
ХȰʲΥǡޤ
(Ĥޤְʬޤ⤢)
ƤӽФ
.BR write (2)
֤ͤȤºݤ˲ХȽޤ줿Τǧ٤Ǥ롣
ޤߤǡ⡢¾Υץǡ
֤뤳Ȥ롣
.SS ץե֥ե饰
ץե֥ե饰Τѥפ FIFO ФựĤΤ
.B O_NONBLOCK
.B O_ASYNC
Ǥ롣
ѥפɤ߽Ф¦
.B O_ASYNC
ե饰åȤȡѥפ˿Ϥȥʥ (ǥեȤǤ
.BR SIGIO )
(ܺ٤
.BR fcntl (2)
)
Linux Ǥϡ
ѥפ FIFO Ф
.B O_ASYNC
ϥͥ 2.6 ʹߤǤΤߥݡȤƤ롣
.SS ܿ˴ؤ
ĤΥƥ (Linux ǤϤʤ) ǤϡѥפǤ롢
Ĥޤѥפξü֤ǥǡξ뤳ȤǤ롣
POSIX.1-2001 Ǥϡѥפϰ̿бƤФ褤
ܿθץꥱǤϡѥפλȤߤ
ˤ٤ǤϤʤ
.SH Ϣ
.BR dup (2),
.BR fcntl (2),
.BR open (2),
.BR pipe (2),
.BR poll (2),
.BR select (2),
.BR socketpair (2),
.BR stat (2),
.BR mkfifo (3),
.BR epoll (7),
.BR fifo (7)
|