OSDN Git Service

93a64b77cb6af616e647831bb9eaa20c7e344913
[linuxjm/LDP_man-pages.git] / draft / man2 / eventfd.2
1 .\" Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" starting from a version by Davide Libenzi <davidel@xmailserver.org>
3 .\"
4 .\" This program is free software; you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation; either version 2 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program; if not, write to the Free Software
16 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 .\" MA  02111-1307  USA
18 .\"
19 .\" 2008-10-10, mtk: describe eventfd2(), and EFD_NONBLOCK and EFD_CLOEXEC
20 .\"
21 .\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
22 .\"         all rights reserved.
23 .\" Translated 2008-04-08, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
24 .\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
25 .\" 
26 .TH EVENTFD 2 2009-01-26 Linux "Linux Programmer's Manual"
27 .\"O .SH NAME
28 .SH 名前
29 .\"O eventfd \- create a file descriptor for event notification
30 eventfd \- イベント通知用のファイルディスクリプタを生成する
31 .\"O .SH SYNOPSIS
32 .SH 書式
33 .B #include <sys/eventfd.h>
34 .sp
35 .BI "int eventfd(unsigned int " initval ", int " flags );
36 .\"O .SH DESCRIPTION
37 .SH 説明
38 .\"O .BR eventfd ()
39 .\"O creates an "eventfd object" that can be used as
40 .\"O an event wait/notify mechanism by userspace applications,
41 .\"O and by the kernel to notify userspace applications of events.
42 .\"O The object contains an unsigned 64-bit integer
43 .\"O .RI ( uint64_t )
44 .\"O counter that is maintained by the kernel.
45 .\"O This counter is initialized with the value specified in the argument
46 .\"O .IR initval .
47 .BR eventfd ()
48 は "eventfd オブジェクト" を生成する。
49 eventfd オブジェクトはユーザ空間アプリケーションがイベント待ち受け/通知用の
50 仕組みとして使うことができる。また、カーネルがユーザ空間アプリケーションに
51 イベントを通知するためにも使うことができる。
52 このオブジェクトには、unsigned の 64 ビット整数
53 .RI ( uint64_t )
54 型のカウンタが含まれており、このカウンタはカーネルにより管理される。
55 このカウンタは
56 .I initval
57 引き数で指定された値で初期化される。
58
59 .\"O Starting with Linux 2.6.27, the following values may be bitwise ORed in
60 .\"O .IR flags
61 .\"O to change the behaviour of
62 .\"O .BR eventfd ():
63 Linux 2.6.27 以降では、
64 以下の値のいくつかをビット単位の論理和 (OR) で指定することで、
65 .BR eventfd ()
66 の振舞いを変更することができる。
67 .TP 14
68 .B EFD_NONBLOCK
69 .\"O Set the
70 .\"O .BR O_NONBLOCK
71 .\"O file status flag on the new open file description.
72 .\"O Using this flag saves extra calls to
73 .\"O .BR fcntl (2)
74 .\"O to achieve the same result.
75 新しく生成されるオープンファイル記述 (open file description) の
76 .B O_NONBLOCK
77 ファイルステータスフラグをセットする。
78 このフラグを使うことで、
79 .B O_NONBLOCK
80 をセットするために
81 .BR fcntl (2)
82 を追加で呼び出す必要がなくなる。
83 .TP
84 .B EFD_CLOEXEC
85 .\"O Set the close-on-exec
86 .\"O .RB ( FD_CLOEXEC )
87 .\"O flag on the new file descriptor.
88 .\"O See the description of the
89 .\"O .B O_CLOEXEC
90 .\"O flag in
91 .\"O .BR open (2)
92 .\"O for reasons why this may be useful.
93 新しいファイルディスクリプタに対して
94 close-on-exec
95 .RB ( FD_CLOEXEC )
96 フラグをセットする。
97 このフラグが役に立つ理由については、
98 .BR open (2)
99
100 .B O_CLOEXEC
101 フラグの説明を参照のこと。
102 .PP
103 .\"O In Linux up to version 2.6.26, the
104 .\"O .I flags
105 .\"O argument is unused, and must be specified as zero.
106 バージョン 2.6.26 以前の Linux では、
107 .I flags
108 引き数は未使用であり、0 を指定しなければならない。
109
110 .\"O As its return value,
111 .\"O .BR eventfd ()
112 .\"O returns a new file descriptor that can be used to refer to the
113 .\"O eventfd object.
114 .\"O The following operations can be performed on the file descriptor:
115 .BR eventfd ()
116 は eventfd オブジェクトを参照するのに使用できる新しいファイルディスクリプタ
117 を返す。返されたファイルディスクリプタに対しては以下の操作を実行できる。
118 .TP
119 .BR read (2)
120 .\"O If the eventfd counter has a nonzero value, then a
121 .\"O .BR read (2)
122 .\"O returns 8 bytes containing that value,
123 .\"O and the counter's value is reset to zero.
124 .\"O (The returned value is in host byte order,
125 .\"O i.e., the native byte order for integers on the host machine.)
126 eventfd カウンタが 0 以外の値の場合、
127 .BR read (2)
128 はカウンタ値を格納した 8 バイトの値を返し、
129 カウンタ値は 0 にリセットされる
130 (返り値はホスト・バイトオーダ、つまり
131 ホストマシンで整数表現に本来使用されるバイトオーダで格納される)。
132 .IP
133 .\"O If the counter is zero at the time of the
134 .\"O .BR read (2),
135 .\"O then the call either blocks until the counter becomes nonzero,
136 .\"O or fails with the error
137 .\"O .B EAGAIN
138 .\"O if the file descriptor has been made nonblocking.
139 .BR read (2)
140 の時点でカウンタが 0 の場合、
141 .BR read (2)
142 はカウンタが 0 以外になるまで停止 (block) する、
143 もしくはファイルディスクリプタが非停止 (nonblocking)
144 に設定されている場合はエラー
145 .B EAGAIN
146 で失敗する。
147 .IP
148 .\"O A
149 .\"O .BR read (2)
150 .\"O will fail with the error
151 .\"O .B EINVAL
152 .\"O if the size of the supplied buffer is less than 8 bytes.
153 渡されたバッファの大きさが 8 バイト未満の場合、
154 .BR read (2)
155 はエラー
156 .B EINVAL
157 で失敗する。
158 .TP
159 .BR write (2)
160 .\"O A
161 .\"O .BR write (2)
162 .\"O call adds the 8-byte integer value supplied in its
163 .\"O buffer to the counter.
164 .\"O The maximum value that may be stored in the counter is the largest
165 .\"O unsigned 64-bit value minus 1 (i.e., 0xfffffffffffffffe).
166 .BR write (2)
167 は、引き数のバッファで渡された 8 バイトの整数値をカウンタに加算する。
168 カウンタに格納可能な最大値は unsigned の 64 ビット整数の最大値から
169 1 を引いた値 (すなわち 0xfffffffffffffffe) である。
170 .\"O If the addition would cause the counter's value to exceed
171 .\"O the maximum, then the
172 .\"O .BR write (2)
173 .\"O either blocks until a
174 .\"O .BR read (2)
175 .\"O is performed on the file descriptor,
176 .\"O or fails with the error
177 .\"O .B EAGAIN
178 .\"O if the file descriptor has been made nonblocking.
179 加算を行うとカウンタ値が最大値を超過する場合には、
180 そのファイルディスクリプタに対して
181 .BR read (2)
182 が実行されるまで、
183 .BR write (2)
184 は停止 (block) する、
185 もしくはファイルディスクリプタが非停止 (nonblocking)
186 に設定されている場合はエラー
187 .B EAGAIN
188 で失敗する。
189 .IP
190 .\"O A
191 .\"O .BR write (2)
192 .\"O will fail with the error
193 .\"O .B EINVAL
194 .\"O if the size of the supplied buffer is less than 8 bytes,
195 .\"O or if an attempt is made to write the value 0xffffffffffffffff.
196 渡されたバッファの大きさが 8 バイト未満の場合、もしくは
197 値 0xffffffffffffffff を書き込もうとした場合、
198 .BR write (2)
199 はエラー
200 .B EINVAL
201 で失敗する。
202 .TP
203 .\"O .BR poll "(2), " select "(2) (and similar)"
204 .BR poll "(2), " select "(2) (と同様の操作)"
205 .\"O The returned file descriptor supports
206 .\"O .BR poll (2)
207 .\"O (and analogously
208 .\"O .BR epoll (7))
209 .\"O and
210 .\"O .BR select (2),
211 .\"O as follows:
212 返されたファイルディスクリプタは、
213 .BR poll (2)
214 .RB ( epoll (7)
215 も同じ) や
216 .BR select (2)
217 をサポートしており、以下のような動作をする。
218 .RS
219 .IP * 3
220 .\"O The file descriptor is readable
221 .\"O (the
222 .\"O .BR select (2)
223 .\"O .I readfds
224 .\"O argument; the
225 .\"O .BR poll (2)
226 .\"O .B POLLIN
227 .\"O flag)
228 .\"O if the counter has a value greater than 0.
229 カウンタが 0 より大きい値の場合、
230 ファイルディスクリプタは読み出し可能となる
231 .RB ( select (2)
232
233 .I readfds
234 引き数や
235 .BR poll (2)
236
237 .B POLLIN
238 フラグ)。
239 .IP *
240 .\"O The file descriptor is writable
241 .\"O (the
242 .\"O .BR select (2)
243 .\"O .I writefds
244 .\"O argument; the
245 .\"O .BR poll (2)
246 .\"O .B POLLOUT
247 .\"O flag)
248 .\"O if it is possible to write a value of at least "1" without blocking.
249 少なくとも値 "1" を、停止 (block) を伴わずに書き込める場合、
250 ファイルディスクリプタは書き込み可能となる
251 .RB ( select (2)
252
253 .I writefds
254 引き数や
255 .BR poll (2)
256
257 .B POLLOUT
258 フラグ)。
259 .IP *
260 .\"O If an overflow of the counter value was detected,
261 .\"O then
262 .\"O .BR select (2)
263 .\"O indicates the file descriptor as being both readable and writable, and
264 .\"O .BR poll (2)
265 .\"O returns a
266 .\"O .B POLLERR
267 .\"O event.
268 カウンタ値のオーバーフローが検出された場合、
269 .BR select (2)
270 はファイルディスクリプタは読み出し可能と書き込み可能の両方を通知し、
271 .BR poll (2)
272
273 .B POLLERR
274 イベントを返す。
275 .\"O As noted above,
276 .\"O .BR write (2)
277 .\"O can never overflow the counter.
278 .\"O However an overflow can occur if 2^64
279 .\"O eventfd "signal posts" were performed by the KAIO
280 .\"O subsystem (theoretically possible, but practically unlikely).
281 .\"O If an overflow has occurred, then
282 .\"O .BR read (2)
283 .\"O will return that maximum
284 .\"O .I uint64_t
285 .\"O value (i.e., 0xffffffffffffffff).
286 上述の通り、
287 .BR write (2)
288 でカウンタがオーバーフローすることは決してない。
289 しかしながら、 KAIO サブシステムによって 2^64 回の eventfd "signal posts" が
290 実行された場合にはオーバーフローが起こり得る
291 (理論的にはあり得るが、実用的にはあり得ない)。
292 オーバーフローが発生した場合、
293 .BR read (2)
294
295 .I uint64_t
296 の最大値 (すなわち 0xffffffffffffffff) を返す。
297 .RE
298 .IP
299 .\"O The eventfd file descriptor also supports the other file-descriptor
300 .\"O multiplexing APIs:
301 .\"O .BR pselect (2),
302 .\"O .BR ppoll (2),
303 .\"O and
304 .\"O .BR epoll (7).
305 eventfd ファイルディスクリプタは、これ以外のファイルディスクリプタ
306 多重 API である
307 .BR pselect (2),
308 .BR ppoll (2),
309 .BR epoll (7)
310 もサポートしている。
311 .TP
312 .BR close (2)
313 .\"O When the file descriptor is no longer required it should be closed.
314 .\"O When all file descriptors associated with the same eventfd object
315 .\"O have been closed, the resources for object are freed by the kernel.
316 ファイルディスクリプタがそれ以降は必要なくなった際には、クローズすべきである。
317 同じ eventfd オブジェクトに関連付けられたファイルディスクリプタが全て
318 クローズされると、そのオブジェクト用の資源がカーネルにより解放される。
319 .PP
320 .\"O A copy of the file descriptor created by
321 .\"O .BR eventfd ()
322 .\"O is inherited by the child produced by
323 .\"O .BR fork (2).
324 .\"O The duplicate file descriptor is associated with the same
325 .\"O eventfd object.
326 .\"O File descriptors created by
327 .\"O .BR eventfd ()
328 .\"O are preserved across
329 .\"O .BR execve (2).
330 .BR fork (2)
331 で生成された子プロセスは、
332 .BR eventfd ()
333 で生成されたファイルディスクリプタのコピーを継承する。
334 複製されたファイルディスクリプタは同じ eventfd オブジェクトに関連付けられる。
335 .BR execve (2)
336 の前後で
337 .BR eventfd ()
338 で生成されたファイルディスクリプタは保持される。
339 .\"O .SH "RETURN VALUE"
340 .SH 返り値
341 .\"O On success,
342 .\"O .BR eventfd ()
343 .\"O returns a new eventfd file descriptor.
344 .\"O On error, \-1 is returned and
345 .\"O .I errno
346 .\"O is set to indicate the error.
347 成功すると、
348 .BR eventfd ()
349 は新規の eventfd ファイルディスクリプタを返す。
350 エラーの場合、\-1 を返し、
351 .I errno
352 にエラーを示す値を設定する。
353 .\"O .SH ERRORS
354 .SH エラー
355 .TP
356 .B EINVAL
357 .\"O .I flags
358 .\"O is invalid;
359 .\"O or, in Linux 2.6.26 or earlier,
360 .\"O .I flags
361 .\"O is nonzero.
362 .I flags
363 が無効。
364 Linux 2.6.26 以前では、
365 .I flags
366 が 0 以外の値。
367 .TP
368 .B EMFILE
369 .\"O The per-process limit on open file descriptors has been reached.
370 オープン済みのファイルディスクリプタの数がプロセスあたりの上限に
371 達していた。
372 .TP
373 .B ENFILE
374 .\"O The system-wide limit on the total number of open files has been
375 .\"O reached.
376 オープン済みのファイル総数がシステム全体の上限に達していた。
377 .TP
378 .B ENODEV
379 .\" Note from Davide:
380 .\" The ENODEV error is basically never going to happen if
381 .\" the kernel boots correctly. That error happen only if during
382 .\" the kernel initialization, some error occur in the anonymous
383 .\" inode source initialization.
384 .\"O Could not mount (internal) anonymous inode device.
385 (カーネル内の) 無名 inode デバイスをマウントできなかった。
386 .TP
387 .B ENOMEM
388 .\"O There was insufficient memory to create a new
389 .\"O eventfd file descriptor.
390 新しい eventfd ファイルディスクリプタを生成するのに十分なメモリがなかった。
391 .\"O .SH VERSIONS
392 .SH バージョン
393 .\"O .BR eventfd ()
394 .\"O is available on Linux since kernel 2.6.22.
395 .\"O Working support is provided in glibc since version 2.8.
396 .BR eventfd ()
397 はカーネル 2.6.22 以降の Linux で利用可能である。
398 正しく動作する glibc 側のサポートはバージョン 2.8 以降で提供されている。
399 .\" eventfd() is in glibc 2.7, but reportedly does not build
400 .\"O The
401 .\"O .BR eventfd2 ()
402 .\"O system call (see NOTES) is available on Linux since kernel 2.6.27.
403 .BR eventfd2 ()
404 システムコール (「注意」参照) は
405 カーネル 2.6.27 以降の Linux で利用可能である。
406 .\"O Since version 2.9, the glibc
407 .\"O .BR eventfd ()
408 .\"O wrapper will employ the
409 .\"O .BR eventfd2 ()
410 .\"O system call, if it is supported by the kernel.
411 バージョン 2.9 以降では、glibc の
412 .BR eventfd ()
413 のラッパー関数は、カーネルが対応していれば
414 .BR eventfd2 ()
415 システムコールを利用する。
416 .\"O .SH CONFORMING TO
417 .SH 準拠
418 .\"O .BR eventfd ()
419 .\"O and
420 .\"O .BR eventfd2 ()
421 .\"O are Linux-specific.
422 .BR eventfd ()
423
424 .BR eventfd2 ()
425 は Linux 固有である。
426 .\"O .SH NOTES
427 .SH 注意
428 .\"O Applications can use an eventfd file descriptor instead of a pipe (see
429 .\"O .BR pipe (2))
430 .\"O in all cases where a pipe is used simply to signal events.
431 .\"O The kernel overhead of an eventfd file descriptor
432 .\"O is much lower than that of a pipe,
433 .\"O and only one file descriptor is
434 .\"O required (versus the two required for a pipe).
435 アプリケーションは、パイプをイベントを通知するためだけに使用している
436 全ての場面において、パイプの代わりに eventfd ファイルディスクリプタを
437 使用することができる。
438 eventfd ファイルディスクリプタを使う方が、パイプを使う場合に比べて
439 カーネルでのオーバヘッドは比べるとずっと小さく、ファイルディスクリプタも
440 一つしか必要としない (パイプの場合は二つ必要である)。
441
442 .\"O When used in the kernel, an eventfd
443 .\"O file descriptor can provide a kernel-userspace bridge allowing,
444 .\"O for example, functionalities like KAIO (kernel AIO)
445 .\"O .\" or eventually syslets/threadlets
446 .\"O to signal to a file descriptor that some operation is complete.
447 カーネル内で使用すると、eventfd ファイルディスクリプタは
448 カーネル空間とユーザ空間のブリッジ機能を提供することができ、
449 例えば KAIO (kernel AIO)
450 .\" や eventually syslets/threadlets
451 のような機能が、あるファイルディスクリプタに何らかの操作が完了したことを
452 通知することができる。
453
454 .\"O A key point about an eventfd file descriptor is that it can be
455 .\"O monitored just like any other file descriptor using
456 .\"O .BR select (2),
457 .\"O .BR poll (2),
458 .\"O or
459 .\"O .BR epoll (7).
460 eventfd ファイルディスクリプタの重要な点は、
461 eventfd ファイルディスクリプタが
462 .BR select (2),
463 .BR poll (2),
464 .BR epoll (7)
465 を使って他のファイルディスクリプタと全く同様に監視できる点である。
466 .\"O This means that an application can simultaneously monitor the
467 .\"O readiness of "traditional" files and the readiness of other
468 .\"O kernel mechanisms that support the eventfd interface.
469 .\"O (Without the
470 .\"O .BR eventfd ()
471 .\"O interface, these mechanisms could not be multiplexed via
472 .\"O .BR select (2),
473 .\"O .BR poll (2),
474 .\"O or
475 .\"O .BR epoll (7).)
476 このことは、アプリケーションは「従来の (traditional)」 ファイルの状態変化と
477 eventfd インタフェースをサポートする他のカーネル機構の状態変化を同時に監視
478 できることを意味する
479 .RB ( eventfd ()
480 インタフェースがない時には、これらのカーネル機構は
481 .BR select (2),
482 .BR poll (2),
483 .BR epoll (7)
484 経由で多重することはできなかった)。
485 .\"O .SS Underlying Linux system calls
486 .SS 下層にある Linux のシステムコール
487 .\"O There are two underlying Linux system calls:
488 .\"O .BR eventfd ()
489 .\"O and the more recent
490 .\"O .BR eventfd2 ().
491 .\"O The former system call does not implement a
492 .\"O .I flags
493 .\"O argument.
494 .\"O The latter system call implements the
495 .\"O .I flags
496 .\"O values described above.
497 下層にある Linux システムコールは二種類あり、
498 .BR eventfd ()
499 と、もっと新しい
500 .BR eventfd2 ()
501 である。
502 .BR eventfd ()
503
504 .I flags
505 引き数を実装していない。
506 .BR eventfd2 ()
507 では上記の値の
508 .I flags
509 が実装されている。
510 .\"O The glibc wrapper function will use
511 .\"O .BR eventfd2 ()
512 .\"O where it is available.
513 glibc のラッパー関数は、
514 .BR eventfd2 ()
515 が利用可能であれば、これを使用する。
516 .\"O .SS Additional glibc features
517 .SS glibc の追加機能
518 .\"O The GNU C library defines an additional type,
519 .\"O and two functions that attempt to abstract some of the details of
520 .\"O reading and writing on an eventfd file descriptor:
521 GNU C ライブラリは、eventfd ファイルディスクリプタの読み出しと書き込みに
522 を関する詳細のいくつか抽象化するために、一つの型と、二つの関数を追加で
523 定義している。
524 .in +4n
525 .nf
526
527 typedef uint64_t eventfd_t;
528
529 int eventfd_read(int fd, eventfd_t *value);
530 int eventfd_write(int fd, eventfd_t value);
531 .fi
532 .in
533
534 .\"O The functions perform the read and write operations on an
535 .\"O eventfd file descriptor,
536 .\"O returning 0 if the correct number of bytes was transferred,
537 .\"O or \-1 otherwise.
538 これらの関数は、eventfd ファイルディスクリプタに対する読み出しと
539 書き込みの操作を実行し、正しいバイト数が転送された場合には
540 0 を返し、そうでない場合は \-1 を返す。
541 .\"O .SH EXAMPLE
542 .SH 例
543 .PP
544 .\"O The following program creates an eventfd file descriptor
545 .\"O and then forks to create a child process.
546 .\"O While the parent briefly sleeps,
547 .\"O the child writes each of the integers supplied in the program's
548 .\"O command-line arguments to the eventfd file descriptor.
549 .\"O When the parent has finished sleeping,
550 .\"O it reads from the eventfd file descriptor.
551 以下のプログラムは eventfd ファイルディスクリプタを生成し、
552 その後 fork を実行して子プロセスを生成する。
553 親プロセスが少しの間 sleep する間に、子プロセスは
554 プログラムのコマンドライン引き数で指定された整数(列)をそれぞれ
555 eventfd ファイルディスクリプタに書き込む。
556 親プロセスは sleep を完了すると eventfd ファイルディスクリプタから
557 読み出しを行う。
558
559 .\"O The following shell session shows a sample run of the program:
560 以下に示すシェルセッションにこのプログラムの使い方を示す。
561 .in +4n
562 .nf
563
564 .RB "$" " ./a.out 1 2 4 7 14"
565 Child writing 1 to efd
566 Child writing 2 to efd
567 Child writing 4 to efd
568 Child writing 7 to efd
569 Child writing 14 to efd
570 Child completed write loop
571 Parent about to read
572 Parent read 28 (0x1c) from efd
573 .fi
574 .in
575 .\"O .SS Program source
576 .SS プログラムのソース
577 \&
578 .nf
579 #include <sys/eventfd.h>
580 #include <unistd.h>
581 #include <stdlib.h>
582 #include <stdio.h>
583 #include <stdint.h>             /* Definition of uint64_t */
584
585 #define handle_error(msg) \\
586     do { perror(msg); exit(EXIT_FAILURE); } while (0)
587
588 int
589 main(int argc, char *argv[])
590 {
591     int efd, j;
592     uint64_t u;
593     ssize_t s;
594
595     if (argc < 2) {
596         fprintf(stderr, "Usage: %s <num>...\\n", argv[0]);
597         exit(EXIT_FAILURE);
598     }
599
600     efd = eventfd(0, 0);
601     if (efd == \-1)
602         handle_error("eventfd");
603
604     switch (fork()) {
605     case 0:
606         for (j = 1; j < argc; j++) {
607             printf("Child writing %s to efd\\n", argv[j]);
608             u = strtoull(argv[j], NULL, 0);
609                     /* strtoull() allows various bases */
610             s = write(efd, &u, sizeof(uint64_t));
611             if (s != sizeof(uint64_t))
612                 handle_error("write");
613         }
614         printf("Child completed write loop\\n");
615
616         exit(EXIT_SUCCESS);
617
618     default:
619         sleep(2);
620
621         printf("Parent about to read\\n");
622         s = read(efd, &u, sizeof(uint64_t));
623         if (s != sizeof(uint64_t))
624             handle_error("read");
625         printf("Parent read %llu (0x%llx) from efd\\n",
626                 (unsigned long long) u, (unsigned long long) u);
627         exit(EXIT_SUCCESS);
628
629     case \-1:
630         handle_error("fork");
631     }
632 }
633 .fi
634 .\"O .SH "SEE ALSO"
635 .SH 関連項目
636 .BR futex (2),
637 .BR pipe (2),
638 .BR poll (2),
639 .BR read (2),
640 .BR select (2),
641 .BR signalfd (2),
642 .BR timerfd_create (2),
643 .BR write (2),
644 .BR epoll (7),
645 .BR sem_overview (7)