OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man2 / select_tut.2
index 44e8f6a..808ad8d 100644 (file)
@@ -1,5 +1,6 @@
 .\" This manpage is copyright (C) 2001 Paul Sheer.
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" 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.
@@ -19,6 +20,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" very minor changes, aeb
 .\"
 .\"             various other changes
 .\" 2008-01-26, mtk, substantial changes and rewrites
 .\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
 .\" Translated 2002-02-21, NAKANO Takeo <nakano@apm.seikei.ac.jp>
 .\" Updated 2002-09-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
 .\" Updated 2005-03-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
 .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
 .\" Updated 2009-02-13, Akihiro MOTOKI, LDP v3.18
 .\"
-.\"WORD:       file descriptor         ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
-.\"WORD:       exceptional condition   Îã³°¾õÂÖ
-.\"
-.TH SELECT_TUT 2 2010-06-10 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH Ì¾Á°
-.\"O select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \-
-.\"O synchronous I/O multiplexing
-select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \- Æ±´ü I/O ¤Î¿½Å²½
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH SELECT_TUT 2 2013\-12\-30 Linux "Linux Programmer's Manual"
+.SH 名前
+select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \- 同期 I/O の多重化
+.SH 書式
 .nf
-.\"O /* According to POSIX.1-2001 */
-/* POSIX.1-2001 ¤Ë½¾¤¦¾ì¹ç */
+/* POSIX.1\-2001 に従う場合 */
 .br
-.B #include <sys/select.h>
+\fB#include <sys/select.h>\fP
 .sp
-.\"O /* According to earlier standards */
-/* °ÊÁ°¤Îµ¬³Ê¤Ë½¾¤¦¾ì¹ç */
+/* 以前の規格に従う場合 */
 .br
-.B #include <sys/time.h>
+\fB#include <sys/time.h>\fP
 .br
-.B #include <sys/types.h>
+\fB#include <sys/types.h>\fP
 .br
-.B #include <unistd.h>
+\fB#include <unistd.h>\fP
 .sp
-.BI "int select(int " nfds ", fd_set *" readfds ", fd_set *" writefds ,
-.BI "           fd_set *" exceptfds ", struct timeval *" utimeout );
+\fBint select(int \fP\fInfds\fP\fB, fd_set *\fP\fIreadfds\fP\fB, fd_set *\fP\fIwritefds\fP\fB,\fP
+\fB           fd_set *\fP\fIexceptfds\fP\fB, struct timeval *\fP\fIutimeout\fP\fB);\fP
 .sp
-.BI "void FD_CLR(int " fd ", fd_set *" set );
+\fBvoid FD_CLR(int \fP\fIfd\fP\fB, fd_set *\fP\fIset\fP\fB);\fP
 .br
-.BI "int  FD_ISSET(int " fd ", fd_set *" set );
+\fBint  FD_ISSET(int \fP\fIfd\fP\fB, fd_set *\fP\fIset\fP\fB);\fP
 .br
-.BI "void FD_SET(int " fd ", fd_set *" set );
+\fBvoid FD_SET(int \fP\fIfd\fP\fB, fd_set *\fP\fIset\fP\fB);\fP
 .br
-.BI "void FD_ZERO(fd_set *" set );
+\fBvoid FD_ZERO(fd_set *\fP\fIset\fP\fB);\fP
 .sp
-.B #include <sys/select.h>
+\fB#include <sys/select.h>\fP
 .sp
-.BI "int pselect(int " nfds ", fd_set *" readfds ", fd_set *" writefds ,
-.BI "            fd_set *" exceptfds ", const struct timespec *" ntimeout ,
-.BI "            const sigset_t *" sigmask );
+\fBint pselect(int \fP\fInfds\fP\fB, fd_set *\fP\fIreadfds\fP\fB, fd_set *\fP\fIwritefds\fP\fB,\fP
+\fB            fd_set *\fP\fIexceptfds\fP\fB, const struct timespec *\fP\fIntimeout\fP\fB,\fP
+\fB            const sigset_t *\fP\fIsigmask\fP\fB);\fP
 .fi
 .sp
 .in -4n
-.\"O Feature Test Macro Requirements for glibc (see
-.\"O .BR feature_test_macros (7)):
-glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
-.RB ( feature_test_macros (7)
-»²¾È):
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
 .in
 .sp
-.BR pselect ():
-_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O .BR select ()
-.\"O (or
-.\"O .BR pselect ())
-.\"O is used to efficiently monitor multiple file descriptors,
-.\"O to see if any of them is, or becomes, "ready";
-.\"O that is, to see whether I/O becomes possible,
-.\"O or an "exceptional condition" has occurred on any of the descriptors.
-.BR select ()
-(¤ä
-.BR pselect ())
-¤ò»È¤¦¤È¡¢¸úΨŪ¤ËÊ£¿ô¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò´Æ»ë¤·¡¢
-¤½¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¤¤º¤ì¤«¤¬
-¡Öready (½àÈ÷¤¬¤Ç¤­¤¿)¡×¾õÂÖ¡¢¤Ä¤Þ¤ê I/O (Æþ½ÐÎÏ) ¤¬²Äǽ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤«¤ä¡¢
-¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¤¤º¤ì¤«¤¬
-¡ÖÎã³°¾õÂÖ (exceptional condition)¡×¤¬È¯À¸¤·¤¿¤«¡¢¤òÄ´¤Ù¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-
-.\"O Its principal arguments are three "sets" of file descriptors:
-.\"O \fIreadfds\fP, \fIwritefds\fP, and \fIexceptfds\fP.
-¤³¤Î´Ø¿ô¤Î¼çÍפʰú¤­¿ô¤Ï¡¢3¼ïÎà¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¡Ö½¸¹ç¡×
-\fIreadfds\fP, \fIwritefds\fP, \fIexceptfds\fP ¤Ç¤¢¤ë¡£
-.\"O Each set is declared as type
-.\"O .IR fd_set ,
-.\"O and its contents can be manipulated with the macros
-.\"O .BR FD_CLR (),
-.\"O .BR FD_ISSET (),
-.\"O .BR FD_SET (),
-.\"O and
-.\"O .BR FD_ZERO ().
-.\"O A newly declared set should first be cleared using
-.\"O .BR FD_ZERO ().
-³Æ¡¹¤Î½¸¹ç¤Ï
-.B fd_set
-¤È¤·¤ÆÀë¸À¤µ¤ì¡¢¤½¤ÎÆâÍƤÏ
-.BR FD_CLR (),
-.BR FD_ISSET (),
-.BR FD_SET (),
-.BR FD_ZERO ()
-¤È¤¤¤Ã¤¿¥Þ¥¯¥í¤Ë¤è¤Ã¤ÆÁàºî¤Ç¤­¤ë¡£
-¿·¤·¤¯Àë¸À¤µ¤ì¤¿½¸¹ç¤Ï¡¢¤Þ¤ººÇ½é¤Ë
-.BR FD_ZERO ()
-¤ò»È¤Ã¤Æ¥¯¥ê¥¢¤¹¤Ù¤­¤Ç¤¢¤ë¡£
-.\"O .BR select ()
-.\"O modifies the contents of the sets according to the rules
-.\"O described below; after calling
-.\"O .BR select ()
-.\"O you can test if a file descriptor is still present in a set with the
-.\"O .BR FD_ISSET ()
-.\"O macro.
-.\"O .BR FD_ISSET ()
-.\"O returns nonzero if a specified file descriptor is present in a set
-.\"O and zero if it is not.
-.\"O .BR FD_CLR ()
-.\"O removes a file descriptor from a set.
-.BR select ()
-¤Ï¤³¤ì¤é¤Î½¸¹ç¤ÎÆâÍƤò¡¢°Ê¹ß¤Ë½Ò¤Ù¤ëµ¬Â§¤Ë½¾¤Ã¤Æ½¤Àµ¤¹¤ë¡£
-.BR select ()
-¤ò¸Æ¤ó¤À¸å¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬¤Þ¤À½¸¹ç¤Ë¸ºß¤·¤Æ¤¤¤ë¤«¤É¤¦¤«¤Ï¡¢
-.BR FD_ISSET ()
-¥Þ¥¯¥í¤Ë¤è¤Ã¤ÆÄ´¤Ù¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-.BR FD_ISSET ()
-¤Ï»ØÄꤵ¤ì¤¿¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬½¸¹ç¤Ë¸ºß¤·¤Æ¤¤¤ì¤Ð 0 °Ê³°¤ÎÃͤòÊÖ¤·¡¢
-¸ºß¤·¤Ê¤±¤ì¤Ð 0 ¤òÊÖ¤¹¡£
-.BR FD_CLR ()
-¤Ï½¸¹ç¤«¤é¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Îºï½ü¤ò¹Ô¤¦¡£
-.\"O .SS Arguments
-.SS °ú¤­¿ô
-.TP
+\fBpselect\fP(): _POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600
+.SH 説明
+\fBselect\fP()  (や \fBpselect\fP())  を使うと、効率的に複数のファイルディスクリプターを監視し、
+そのファイルディスクリプターのいずれかが 「ready (準備ができた)」状態、つまり I/O (入出力) が可能になっているかや、
+ファイルディスクリプターのいずれかが 「例外状態 (exceptional condition)」が発生したか、を調べることができる。
+
+この関数の主要な引き数は、3種類のファイルディスクリプターの「集合」 \fIreadfds\fP, \fIwritefds\fP, \fIexceptfds\fP
+である。 各々の集合は \fBfd_set\fP として宣言され、その内容は \fBFD_CLR\fP(), \fBFD_ISSET\fP(), \fBFD_SET\fP(),
+\fBFD_ZERO\fP()  といったマクロによって操作できる。 新しく宣言された集合は、まず最初に \fBFD_ZERO\fP()
+を使ってクリアすべきである。 \fBselect\fP()  はこれらの集合の内容を、以降に述べる規則に従って修正する。 \fBselect\fP()
+を呼んだ後、ファイルディスクリプターがまだ集合に存在しているかどうかは、 \fBFD_ISSET\fP()  マクロによって調べることができる。
+\fBFD_ISSET\fP()  は指定されたディスクリプターが集合に存在していれば 0 以外の値を返し、 存在しなければ 0 を返す。
+\fBFD_CLR\fP()  は集合からのファイルディスクリプターの削除を行う。
+.SS 引き数
+.TP 
 \fIreadfds\fP
-.\"O This set is watched to see if data is available for reading from any of
-.\"O its file descriptors.
-.\"O After
-.\"O .BR select ()
-.\"O has returned, \fIreadfds\fP will be
-.\"O cleared of all file descriptors except for those that
-.\"O are immediately available for reading.
-¤³¤Î½¸¹ç¤Ë´Þ¤Þ¤ì¤ë¤¤¤º¤ì¤«¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¡¢
-¥Ç¡¼¥¿¤ÎÆɤ߹þ¤ß¤¬²Äǽ¤Ë¤Ê¤Ã¤¿¤«¤É¤¦¤«¤ò´Æ»ë¤¹¤ë¡£
-.BR select ()
-¤«¤éÌá¤ë»þ¤Ë¡¢\fIreadfds\fP ¤Î¤¦¤Á¡¢
-ľ¤Á¤ËÆɤ߹þ¤ß²Äǽ¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿°Ê³°¤Ï
-½¸¹ç¤«¤éºï½ü¤µ¤ì¤ë¡£
-.TP
+この集合に含まれるいずれかのファイルディスクリプターで、 データの読み込みが可能になったかどうかを監視する。 \fBselect\fP()
+から戻る時に、\fIreadfds\fP のうち、 直ちに読み込み可能なファイルディスクリプター以外は 集合から削除される。
+.TP 
 \fIwritefds\fP
-.\"O This set is watched to see if there is space to write data to any of
-.\"O its file descriptors.
-.\"O After
-.\"O .BR select ()
-.\"O has returned, \fIwritefds\fP will be
-.\"O cleared of all file descriptors except for those that
-.\"O are immediately available for writing.
-¤³¤Î½¸¹ç¤Ë´Þ¤Þ¤ì¤ë¤¤¤º¤ì¤«¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¡¢
-¥Ç¡¼¥¿¤ò½ñ¤­¹þ¤à¥¹¥Ú¡¼¥¹¤¬¤¢¤ë¤«¤É¤¦¤«¤ò´Æ»ë¤¹¤ë¡£
-.BR select ()
-¤«¤éÌá¤ë»þ¤Ë¡¢\fIwritefds\fP ¤Î¤¦¤Á¡¢
-ľ¤Á¤Ë½ñ¤­¹þ¤ß²Äǽ¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿°Ê³°¤Ï
-½¸¹ç¤«¤éºï½ü¤µ¤ì¤ë¡£
-.TP
+この集合に含まれるいずれかのファイルディスクリプターで、 データを書き込むスペースがあるかどうかを監視する。 \fBselect\fP()
+から戻る時に、\fIwritefds\fP のうち、 直ちに書き込み可能なファイルディスクリプター以外は 集合から削除される。
+.TP 
 \fIexceptfds\fP
-.\"O This set is watched for "exceptional conditions".
-.\"O In practice, only one such exceptional condition is common:
-.\"O the availability of \fIout-of-band\fP (OOB) data for reading
-.\"O from a TCP socket.
-.\"O See
-.\"O .BR recv (2),
-.\"O .BR send (2),
-.\"O and
-.\"O .BR tcp (7)
-.\"O for more details about OOB data.
-.\"O (One other less common case where
-.\"O .BR select (2)
-.\"O indicates an exceptional condition occurs with pseudoterminals
-.\"O in packet mode; see
-.\"O .BR tty_ioctl (4).)
-.\"O After
-.\"O .BR select ()
-.\"O has returned,
-.\"O \fIexceptfds\fP will be cleared of all file descriptors except for those
-.\"O for which an exceptional condition has occurred.
-¤³¤Î½¸¹ç¤Ë´Þ¤Þ¤ì¤ë¤¤¤º¤ì¤«¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¡¢
-¡ÖÎã³°¾õÂÖ (exceptional condition)¡×¤¬È¯À¸¤·¤¿¤«¤É¤¦¤«¤ò´Æ»ë¤¹¤ë¡£
-¼ÂºÝ¤ÎÆ°ºî¤Ç¤Ï¡¢ÉáÄ̤˵¯¤³¤êÆÀ¤ëÎã³°¾õÂ֤ϰì¤Ä¤À¤±¤Ç¤¢¤ê¡¢
-¤½¤ì¤Ï TCP ¥½¥±¥Ã¥È¤Ç \fIÂÓ°è³° (out-of-band; OOB)\fP ¥Ç¡¼¥¿¤¬
-Æɤ߹þ¤ß²Äǽ¤Ê¾ì¹ç¤Ç¤¢¤ë¡£
-OOB ¥Ç¡¼¥¿¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢
-.BR recv (2),
-.BR send (2),
-.BR tcp (7)
-¤ò»²¾È¤Î¤³¤È¡£
-(¤³¤ì°Ê³°¤Ç¤Ï¡¢¤Þ¤ì¤Ê¤³¤È¤À¤¬¡¢
-¥Ñ¥±¥Ã¥È¥â¡¼¥É¤Îµ¼»÷üËö (pseudoterminals) ¤Ç
-.BR select ()
-¤¬Îã³°¾õÂÖ¤ò¼¨¤¹¤³¤È¤¬¤¢¤ë¡£)
-.BR select ()
-¤¬ÊÖ¤ë»þ¤Ë¡¢\fIexceptfds\fP ¤Î¤¦¤Á¡¢
-Îã³°¾õÂÖ¤¬È¯À¸¤·¤¿¥Ç¥£¥¹¥¯¥ê¥×¥¿°Ê³°¤Ï½¸¹ç¤«¤éºï½ü¤µ¤ì¤ë¡£
-.TP
+この集合に含まれるいずれかのファイルディスクリプターで、 「例外状態 (exceptional condition)」が発生したかどうかを監視する。
+実際の動作では、普通に起こり得る例外状態は一つだけであり、 それは TCP ソケットで \fI帯域外 (out\-of\-band; OOB)\fP データが
+読み込み可能な場合である。 OOB データの詳細については、 \fBrecv\fP(2), \fBsend\fP(2), \fBtcp\fP(7)  を参照のこと。
+(これ以外では、まれなことだが、 パケットモードの擬似端末 (pseudoterminals) で \fBselect\fP()
+が例外状態を示すことがある。)  \fBselect\fP()  が返る時に、\fIexceptfds\fP のうち、
+例外状態が発生したディスクリプター以外は集合から削除される。
+.TP 
 \fInfds\fP
-.\"O This is an integer one more than the maximum of any file descriptor in
-.\"O any of the sets.
-.\"O In other words, while adding file descriptors to each of the sets,
-.\"O you must calculate the maximum integer value of all of them,
-.\"O then increment this value by one, and then pass this as \fInfds\fP.
-Á´¤Æ¤Î½¸¹ç¤Ë´Þ¤Þ¤ì¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¦¤Á¡¢
-Ãͤ¬ºÇÂç¤Î¤â¤Î¤Ë 1 ¤ò­¤·¤¿À°¿ô¤Ç¤¢¤ë¡£
-¤¹¤Ê¤ï¤Á¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò³Æ½¸¹ç¤Ë²Ã¤¨¤ëºî¶È¤ÎÅÓÃæ¤Ç¡¢
-Á´¤Æ¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¸«¤ÆºÇÂçÃͤòµá¤á¡¢
-¤½¤ì¤Ë 1 ¤ò²Ã¤¨¤Æ \fInfds\fP ¤È¤·¤ÆÅϤµ¤Ê¤¤¤È¤¤¤±¤Ê¤¤¡¢¤È¤¤¤¦¤³¤È¤À¡£
-.TP
+全ての集合に含まれるファイルディスクリプターのうち、 値が最大のものに 1 を足した整数である。
+すなわち、ファイルディスクリプターを各集合に加える作業の途中で、 全てのファイルディスクリプターを見て最大値を求め、 それに 1 を加えて
+\fInfds\fP として渡さないといけない、ということだ。
+.TP 
 \fIutimeout\fP
-.\"O This is the longest time
-.\"O .BR select ()
-.\"O may wait before returning, even if nothing interesting happened.
-.\"O If this value is passed as NULL, then
-.\"O .BR select ()
-.\"O blocks indefinitely waiting for a file descriptor to become ready.
-.\"O \fIutimeout\fP can be set to zero seconds, which causes
-.\"O .BR select ()
-.\"O to return immediately, with information about the readiness
-.\"O of file descriptors at the time of the call.
-.\"O The structure \fIstruct timeval\fP is defined as:
-(²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë)
-.BR select ()
-¤¬Ìá¤ëÁ°¤ËÂԤĺÇÂç»þ´Ö¤Ç¤¢¤ë¡£
-¤³¤ÎÃͤˠNULL ¤òÅϤ¹¤È¡¢
-.BR select ()
-¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¤¤º¤ì¤«¤¬ ready (½àÈ÷¤¬¤Ç¤­¤¿) ¾õÂÖ¤Ë
-¤Ê¤ë¤Þ¤ÇÂÔ¤Á³¤±¤Æ¤º¤Ã¤ÈÄä»ß¤¹¤ë¡£
-\fIutimeout\fP ¤Ï 0 Éäˤ¹¤ë¤³¤È¤â¤Ç¤­¡¢
-¤³¤Î¾ì¹ç
-.BR select ()
-¤Ïľ¤Á¤ËÊ֤ꡢ¸Æ¤Ó½Ð¤·»þÅÀ¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¾õÂÖ¤Ë
-´Ø¤¹¤ë¾ðÊó¤¬ÊÖ¤µ¤ì¤ë¡£
-¹½Â¤ÂΠ\fIstruct timeval\fP ¤Ï¼¡¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
+(何も起こらなかった場合に)  \fBselect\fP()  が戻る前に待つ最大時間である。 この値に NULL を渡すと、 \fBselect\fP()
+はファイルディスクリプターのいずれかが ready (準備ができた) 状態に なるまで待ち続けてずっと停止する。 \fIutimeout\fP は 0
+秒にすることもでき、 この場合 \fBselect\fP()  は直ちに返り、呼び出し時点のファイルディスクリプターの状態に 関する情報が返される。 構造体
+\fIstruct timeval\fP は次のように定義されている:
 .IP
 .in +4n
 .nf
@@ -271,21 +130,11 @@ struct timeval {
 };
 .fi
 .in
-.TP
+.TP 
 \fIntimeout\fP
-.\"O This argument for
-.\"O .BR pselect ()
-.\"O has the same meaning as
-.\"O .IR utimeout ,
-.\"O but
-.\"O .I "struct timespec"
-.\"O has nanosecond precision as follows:
-.BR pselect ()
-¤Î¤³¤Î°ú¤­¿ô¤Ï
-.I utimeout
-¤ÈƱ¤¸°ÕÌ£¤ò»ý¤Ä¤¬¡¢
-.I "struct timespec"
-¤Ï¼¡¤Ë¼¨¤¹¤è¤¦¤Ë¥Ê¥ÎÉäÎÀºÅÙ¤ò»ý¤Ä¡£
+\fBpselect\fP()  のこの引き数は \fIutimeout\fP と同じ意味を持つが、 \fIstruct timespec\fP
+は次に示すようにナノ秒の精度を持つ。
+.IP
 .in +4n
 .nf
 struct timespec {
@@ -294,130 +143,25 @@ struct timespec {
 };
 .fi
 .in
-.TP
+.TP 
 \fIsigmask\fP
-.\"O This argument holds a set of signals that the kernel should unblock
-.\"O (i.e., remove from the signal mask of the calling thread),
-.\"O while the caller is blocked inside the
-.\"O .BR pselect ()
-.\"O call (see
-.\"O .BR sigaddset (3)
-.\"O and
-.\"O .BR sigprocmask (2)).
-.\"O It may be NULL,
-.\"O in which case the call does not modify the signal mask on
-.\"O entry and exit to the function.
-.\"O In this case,
-.\"O .BR pselect ()
-.\"O will then behave just like
-.\"O .BR select ().
-¤³¤Î°ú¤­¿ô¤Ï¡¢¸Æ¤Ó½Ð¤·Â¦¤¬
-.BR pselect ()
-ÆâÉô¤ÇÄä»ß¤·¤Æ¤¤¤ë´Ö¤Ë¡¢¥«¡¼¥Í¥ë¤¬ÄÌÃΤòµö²Ä¤¹¤Ù¤­¥·¥°¥Ê¥ë½¸¹ç
-(¤¹¤Ê¤ï¤Á¡¢¸Æ¤Ó½Ð¤·¤¿¥¹¥ì¥Ã¥É¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤«¤éºï½ü¤¹¤Ù¤­¥·¥°¥Ê¥ë½¸¹ç)
-¤òÊÝ»ý¤¹¤ë
-.RB ( sigaddset (3)
-¤È
-.BR sigprocmask (2)
-¤ò»²¾È)¡£
-¤³¤Î°ú¤­¿ô¤Ï NULL ¤Ë¤¹¤ë¤³¤È¤â¤Ç¤­¡¢¤½¤Î¾ì¹ç¤Ï¤³¤Î´Ø¿ô¤Ø
-Æþ¤ë¤È¤­¡¦½Ð¤ë¤È¤­¤Ë¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤òÊѹ¹¤·¤Ê¤¤¡£
-¤³¤Î¾ì¹ç¡¢
-.BR pselect ()
-¤Ï
-.BR select ()
-¤ÈÁ´¤¯Æ±¤¸Æ°ºî¤È¤Ê¤ë¡£
-.\"O .SS Combining Signal and Data Events
-.SS ¥·¥°¥Ê¥ë¤È¥Ç¡¼¥¿¥¤¥Ù¥ó¥È¤òÁȤ߹ç¤ï¤»¤ë
-.\"O .BR pselect ()
-.\"O is useful if you are waiting for a signal as well as
-.\"O for file descriptor(s) to become ready for I/O.
-.\"O Programs that receive signals
-.\"O normally use the signal handler only to raise a global flag.
-.\"O The global flag will indicate that the event must be processed
-.\"O in the main loop of the program.
-¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬ I/O ²Äǽ¤Ê¾õÂ֤ˤʤë¤Î¤ÈƱ»þ¤Ë
-¥·¥°¥Ê¥ë¤âÂÔ¤Á¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢
-.BR pselect ()
-¤¬ÊØÍø¤Ç¤¢¤ë¡£
-¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¥×¥í¥°¥é¥à¤Ï¡¢Ä̾ï¤Ï¡¢
-¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ò¥°¥í¡¼¥Ð¥ë¤Ê¥Õ¥é¥°¤òΩ¤Æ¤ë¤¿¤á¤À¤±¤Ë»È¤¦¡£
-¤³¤Î¥°¥í¡¼¥Ð¥ë¤Ê¥Õ¥é¥°¤Ï¡¢
-¤½¤Î¥¤¥Ù¥ó¥È¤ò¥×¥í¥°¥é¥à¤Î¥á¥¤¥ó¥ë¡¼¥×¤Ç
-½èÍý¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤³¤È¤ò¼¨¤¹¡£
-.\"O A signal will cause the
-.\"O .BR select ()
-.\"O (or
-.\"O .BR pselect ())
-.\"O call to return with \fIerrno\fP set to \fBEINTR\fP.
-.\"O This behavior is essential so that signals can be processed
-.\"O in the main loop of the program, otherwise
-.\"O .BR select ()
-.\"O would block indefinitely.
-¥·¥°¥Ê¥ë¤ò¼õ¤±¤ë¤È
-.BR select ()
-(¤ä
-.BR pselect ())
-¤Ï
-\fIerrno\fP ¤Ë \fBEINTR\fP ¤ò¥»¥Ã¥È¤·¤ÆÌá¤ë¤³¤È¤Ë¤Ê¤ë¡£
-¥·¥°¥Ê¥ë¤¬¥×¥í¥°¥é¥à¤Î¥á¥¤¥ó¥ë¡¼¥×¤Ç½èÍý¤µ¤ì¤ë¤¿¤á¤Ë¤Ï¤³¤ÎÆ°ºî¤¬ÉԲķç¤Ç¡¢
-¤³¤ì¤¬¤Ê¤¤¤È
-.BR select ()
-¤Ï±Ê±ó¤ËÄä»ß¤·Â³¤±¤ë¤³¤È¤Ë¤Ê¤ë¡£
-.\"O Now, somewhere
-.\"O in the main loop will be a conditional to check the global flag.
-.\"O So we must ask:
-.\"O what if a signal arrives after the conditional, but before the
-.\"O .BR select ()
-.\"O call?
-.\"O The answer is that
-.\"O .BR select ()
-.\"O would block indefinitely, even though an event is actually pending.
-¤µ¤Æ¡¢¥á¥¤¥ó¥ë¡¼¥×¤Î¤É¤³¤«¤Ë¤³¤Î¥°¥í¡¼¥Ð¥ë¥Õ¥é¥°¤ò¥Á¥§¥Ã¥¯¤¹¤ë
-¾ò·ïʸ¤¬¤¢¤ë¤È¤·¤è¤¦¡£¤³¤³¤Ç¾¯¤·¹Í¤¨¤Æ¤ß¤Ê¤¤¤È¤¤¤±¤Ê¤¤¡£
-¡Ö¥·¥°¥Ê¥ë¤¬¾ò·ïʸ¤Î¸å¡¢¤·¤«¤·
-.BR select ()
-¥³¡¼¥ë¤ÎÁ°¤ËÅþÃ夷¤¿¤é
-¤É¤¦¤Ê¤ë¤Î¤«¡©¡×
-Åú¤¨¤Ï¡Ö¤½¤Î
-.BR select ()
-¤Ï¡¢¤¿¤È¤¨²ò·èÂÔ¤Á¤Î¥¤¥Ù¥ó¥È¤¬¤¢¤Ã¤¿¤È¤·¤Æ¤â¡¢
-±Ê±ó¤ËÄä»ß¤¹¤ë¡×¤Ç¤¢¤ë¡£
-.\"O This race condition is solved by the
-.\"O .BR pselect ()
-.\"O call.
-.\"O This call can be used to set the signal mask to a set of signals
-.\"O that are only to be received within the
-.\"O .BR pselect ()
-.\"O call.
-¤³¤Î¶¥¹ç¾õÂÖ¤Ï
-.BR pselect ()
-¥³¡¼¥ë¤Ë¤è¤Ã¤Æ²ò·è¤Ç¤­¤ë¡£
-¤³¤Î¥³¡¼¥ë¤ò»È¤¦¤È¡¢
-.BR pselect ()
-¤Ç¼õ¿®¤·¤¿¤¤¥·¥°¥Ê¥ë¤Î½¸¹ç¤À¤±¤ò¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ËÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-.\"O For instance, let us say that the event in question
-.\"O was the exit of a child process.
-.\"O Before the start of the main loop, we
-.\"O would block \fBSIGCHLD\fP using
-.\"O .BR sigprocmask (2).
-.\"O Our
-.\"O .BR pselect ()
-.\"O call would enable
-.\"O .B SIGCHLD
-.\"O by using an empty signal mask.
-.\"O Our program would look like:
-Î㤨¤Ð¡¢ÌäÂê¤È¤Ê¤Ã¤Æ¤¤¤ë¥¤¥Ù¥ó¥È¤¬»Ò¥×¥í¥»¥¹¤Î½ªÎ»¤Î¾ì¹ç¤ò¹Í¤¨¤è¤¦¡£
-¥á¥¤¥ó¥ë¡¼¥×¤¬»Ï¤Þ¤ëÁ°¤Ë¡¢
-.B SIGCHLD
-¤ò
-.BR sigprocmask (2)
-¤Ç¥Ö¥í¥Ã¥¯¤¹¤ë¡£
-.BR pselect ()
-¥³¡¼¥ë¤Ç¤Ï
-.B SIGCHLD
-¤ò¡¢¤â¤È¤â¤È¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ò»È¤Ã¤ÆÍ­¸ú¤Ë¤¹¤ë¤Î¤À¡£
-¤³¤Î¥×¥í¥°¥é¥à¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ë¡£
+この引き数は、呼び出し側が \fBpselect\fP()  内部で停止している間に、カーネルが通知を許可すべきシグナル集合
+(すなわち、呼び出したスレッドのシグナルマスクから削除すべきシグナル集合)  を保持する (\fBsigaddset\fP(3)  と
+\fBsigprocmask\fP(2)  を参照)。 この引き数は NULL にすることもでき、その場合はこの関数へ
+入るとき・出るときにシグナルマスクを変更しない。 この場合、 \fBpselect\fP()  は \fBselect\fP()  と全く同じ動作となる。
+.SS シグナルとデータイベントを組み合わせる
+ファイルディスクリプターが I/O 可能な状態になるのと同時に シグナルも待ちたい場合には、 \fBpselect\fP()  が便利である。
+シグナルを受信するプログラムは、通常は、 シグナルハンドラーをグローバルなフラグを立てるためだけに使う。 このグローバルなフラグは、
+そのイベントをプログラムのメインループで 処理しなければならないことを示す。 シグナルを受けると \fBselect\fP()  (や
+\fBpselect\fP())  は \fIerrno\fP に \fBEINTR\fP をセットして戻ることになる。
+シグナルがプログラムのメインループで処理されるためにはこの動作が不可欠で、 これがないと \fBselect\fP()  は永遠に停止し続けることになる。
+さて、メインループのどこかにこのグローバルフラグをチェックする 条件文があるとしよう。ここで少し考えてみないといけない。 「シグナルが条件文の後、しかし
+\fBselect\fP()  コールの前に到着したら どうなるのか?」 答えは「その \fBselect\fP()
+は、たとえ解決待ちのイベントがあったとしても、 永遠に停止する」である。 この競合状態は \fBpselect\fP()  コールによって解決できる。
+このコールを使うと、 \fBpselect\fP() でのみ受信したいシグナルの集合をシグナルマスクに設定することができる。
+例えば、問題となっているイベントが子プロセスの終了の場合を考えよう。 メインループが始まる前に、 \fBSIGCHLD\fP を
+\fBsigprocmask\fP(2)  でブロックする。 \fBpselect\fP()  コールでは \fBSIGCHLD\fP
+を、もともとのシグナルマスクを使って有効にするのだ。 このプログラムは次のようになる。
 .PP
 .nf
 static volatile sig_atomic_t got_SIGCHLD = 0;
@@ -474,301 +218,83 @@ main(int argc, char *argv[])
     }
 }
 .fi
-.\"O .SS Practical
-.SS ¼ÂÎã
-.\"O So what is the point of
-.\"O .BR select ()?
-.\"O Can't I just read and write to my descriptors whenever I want?
-.\"O The point of
-.\"O .BR select ()
-.\"O is that it watches
-.\"O multiple descriptors at the same time and properly puts the process to
-.\"O sleep if there is no activity.
-.\"O UNIX programmers often find
-.\"O themselves in a position where they have to handle I/O from more than one
-.\"O file descriptor where the data flow may be intermittent.
-.\"O If you were to merely create a sequence of
-.\"O .BR read (2)
-.\"O and
-.\"O .BR write (2)
-.\"O calls, you would
-.\"O find that one of your calls may block waiting for data from/to a file
-.\"O descriptor, while another file descriptor is unused though ready for I/O.
-.\"O .BR select ()
-.\"O efficiently copes with this situation.
-¼ÂºÝ¤Î¤È¤³¤í
-.BR select ()
-¤ÎÂç»ö¤ÊÅÀ¤Ï²¿¤Ê¤Î¤«¡©
-¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¹¥¤­¤Ê¤È¤­¤ËÆɤ߽ñ¤­¤Ç¤­¤ë¤ó¤¸¤ã¤Ê¤¤¤Î¡©
-.BR select ()
-¤Î½ÅÍפʤȤ³¤í¤Ï¡¢Ê£¿ô¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òƱ»þ¤Ë´Æ»ë¤Ç¤­¡¢
-¤Ê¤ó¤ÎÆ°¤­¤â¤Ê¤±¤ì¤Ð¥×¥í¥»¥¹¤òŬÀڤ˥¹¥ê¡¼¥×¾õÂ֤˰ܹԤ¹¤ë¤È¤³¤í¤Ë¤¢¤ë¤Î¤À¡£
-UNIX ¥×¥í¥°¥é¥Þ¤Ï¡¢
-Ê£¿ô¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÆþ½ÐÎϤòƱ»þ¤Ë°·¤ï¤Í¤Ð¤Ê¤é¤º¡¢
-¤·¤«¤â¥Ç¡¼¥¿¤Îή¤ì¤Ï´Ö·çŪ¤Ç¤¢¤ë¡¢¤È¤¤¤¦¾õ¶·¤Ë¤è¤¯½Ð²ñ¤¦¡£
-ñ¤Ë
-.BR read (2)
-¤ä
-.BR write (2)
-¥³¡¼¥ë¤Î¥·¡¼¥±¥ó¥¹¤òºî¤ë¤À¤±¤Ç¤Ï¡¢¤½¤ì¤é¤Î¥³¡¼¥ë¤Î¤É¤ì¤«¤¬
-¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤«¤é¤Î¥Ç¡¼¥¿¤òÂԤäƥ֥í¥Ã¥¯¤·¤Æ¤ª¤ê¡¢
-Ê̤Υե¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë¤Ï I/O ¤¬²Äǽ¤Ê¤Î¤Ë»È¤¨¤Ê¤¤¡¢
-¤È¤¤¤¦¤³¤È¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¤À¤í¤¦¡£
-.BR select ()
-¤ò»È¤¦¤È¤³¤Î¾õ¶·¤Ë¸ú²ÌŪ¤ËÂнè¤Ç¤­¤ë¡£
-.\"O .SS Select Law
-.SS SELECT ¤ÎÙÝ
-.\"O Many people who try to use
-.\"O .BR select ()
-.\"O come across behavior that is
-.\"O difficult to understand and produces nonportable or borderline results.
-.\"O For instance, the above program is carefully written not to
-.\"O block at any point, even though it does not set its file descriptors to
-.\"O nonblocking mode.
-.\"O It is easy to introduce
-.\"O subtle errors that will remove the advantage of using
-.\"O .BR select (),
-.\"O so here is a list of essentials to watch for when using
-.\"O .BR select ().
-.BR select ()
-¤ò»È¤ª¤¦¤È¤·¤¿Â¿¤¯¤Î¿Í¤Ï¡¢Íý²ò¤·¤Ë¤¯¤¤µóÆ°¤Ë½Ð¤¯¤ï¤·¡¢·ë²ÌŪ¤Ë
-¤Ç¤­¤¿¤â¤Î¤Ï°Ü¿¢À­¤¬¤Ê¤¤¤«¡¢¤è¤¯¤Æ¤â¥®¥ê¥®¥ê¤Î¤â¤Î¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¡£
-Î㤨¤Ð¡¢¾åµ­¤Î¥×¥í¥°¥é¥à¤Ï¡¢
-½¸¹ç¤Ë´Þ¤Þ¤ì¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÈóÄä»ß (nonblocking) ¥â¡¼¥É
-¤Ë¤·¤Ê¤¯¤Æ¤â¡¢¤É¤³¤Ë¤â¥Ö¥í¥Ã¥¯¤¬À¸¤¸¤Ê¤¤¤è¤¦Ãí°Õ¤·¤Æ½ñ¤«¤ì¤Æ¤¤¤ë¡£
-Èù̯¤Ê´Ö°ã¤¤¤Ë¤è¤Ã¤Æ¡¢
-.BR select ()
-¤ò»È¤¦ÍøÅÀ¤Ï´Êñ¤Ë¼º¤ï¤ì¤Æ¤·¤Þ¤¦¡£
-¤½¤³¤Ç¡¢
-.BR select ()
-¥³¡¼¥ë¤ò»È¤¦¤È¤­¤ËÃí°Õ¤¹¤Ù¤­½ÅÍ×»ö¹à¤òÎóµó¤·¤Æ¤ª¤¯¤³¤È¤Ë¤¹¤ë¡£
-.TP 4
+.SS 実例
+実際のところ \fBselect\fP()  の大事な点は何なのか? ディスクリプターは好きなときに読み書きできるんじゃないの? \fBselect\fP()
+の重要なところは、複数のディスクリプターを同時に監視でき、 なんの動きもなければプロセスを適切にスリープ状態に移行するところにあるのだ。 UNIX
+プログラマは、 複数のファイルディスクリプターの入出力を同時に扱わねばならず、 しかもデータの流れは間欠的である、という状況によく出会う。 単に
+\fBread\fP(2)  や \fBwrite\fP(2)  コールのシーケンスを作るだけでは、それらのコールのどれかが
+ファイルディスクリプターからのデータを待ってブロックしており、 別のファイルディスクリプターには I/O が可能なのに使えない、
+ということになってしまうだろう。 \fBselect\fP()  を使うとこの状況に効果的に対処できる。
+.SS "SELECT の掟"
+\fBselect\fP()  を使おうとした多くの人は、理解しにくい挙動に出くわし、結果的に
+できたものは移植性がないか、よくてもギリギリのものになってしまう。 例えば、上記のプログラムは、 集合に含まれるファイルディスクリプターを非停止
+(nonblocking) モード にしなくても、どこにもブロックが生じないよう注意して書かれている。 微妙な間違いによって、 \fBselect\fP()
+を使う利点は簡単に失われてしまう。 そこで、 \fBselect\fP()  コールを使うときに注意すべき重要事項を列挙しておくことにする。
+.TP  4
 1.
-.\"O You should always try to use
-.\"O .BR select ()
-.\"O without a timeout.
-.\"O Your program
-.\"O should have nothing to do if there is no data available.
-.\"O Code that
-.\"O depends on timeouts is not usually portable and is difficult to debug.
-.BR select ()
-¤ò»È¤¦¤È¤­¤Ï¡¢¥¿¥¤¥à¥¢¥¦¥È¤ÏÀßÄꤹ¤Ù¤­¤Ç¤Ê¤¤¡£
-½èÍý¤¹¤ë¥Ç¡¼¥¿¤¬Ìµ¤¤¤È¤­¤Ë¤Ï¡¢
-¤¢¤Ê¤¿¤Î¥×¥í¥°¥é¥à¤Ë¤Ï²¿¤â¤¹¤ë¤³¤È¤Ï̵¤¤¤Ï¤º¤Ç¤¢¤ë¡£
-¥¿¥¤¥à¥¢¥¦¥È¤Ë°Í¸¤·¤¿¥³¡¼¥É¤ÏÄ̾ï°Ü¿¢À­¤¬¤Ê¤¯¡¢
-¥Ç¥Ð¥Ã¥°¤âÆñ¤·¤¯¤Ê¤ë¡£
-.TP
+\fBselect\fP()  を使うときは、タイムアウトは設定すべきでない。 処理するデータが無いときには、
+あなたのプログラムには何もすることは無いはずである。 タイムアウトに依存したコードは通常移植性がなく、 デバッグも難しくなる。
+.TP 
 2.
-.\"O The value \fInfds\fP must be properly calculated for efficiency as
-.\"O explained above.
-¾å½Ò¤·¤¿¤è¤¦¤Ë¡¢
-¸úΨŪ¤Ê¥×¥í¥°¥é¥à¤ò½ñ¤¯¤Ë¤Ï
-.I nfds
-¤ÎÃͤòŬÀڤ˷׻»¤·¤ÆÍ¿¤¨¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
-.TP
+上述したように、 効率的なプログラムを書くには \fInfds\fP の値を適切に計算して与えなければならない。
+.TP 
 3.
-.\"O No file descriptor must be added to any set if you do not intend
-.\"O to check its result after the
-.\"O .BR select ()
-.\"O call, and respond appropriately.
-.\"O See next rule.
-.BR select ()
-¥³¡¼¥ë¤Î½ªÎ»¸å¤Ë·ë²Ì¤ò¥Á¥§¥Ã¥¯¤·¤Æ¡¢
-ŬÀÚ¤ËÂбþ¤¹¤ë¤Ä¤â¤ê¤Î¤Ê¤¤¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢
-¤É¤Î½¸¹ç¤Ë¤â²Ã¤¨¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
-¼¡¤Î¥ë¡¼¥ë¤â»²¾È¡£
-.TP
+\fBselect\fP()  コールの終了後に結果をチェックして、 適切に対応するつもりのないファイルディスクリプターは、 どの集合にも加えてはならない。
+次のルールも参照。
+.TP 
 4.
-.\"O After
-.\"O .BR select ()
-.\"O returns, all file descriptors in all sets
-.\"O should be checked to see if they are ready.
-.BR select ()
-¤«¤éÊ֤俸å¤Ë¤Ï¡¢Á´¤Æ¤Î½¸¹ç¤ÎÁ´¤Æ¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë¤Ä¤¤¤Æ
-Æɤ߽ñ¤­²Äǽ¤Ê¾õÂ֤ˤʤäƤ¤¤ë¤«¤ò¥Á¥§¥Ã¥¯¤¹¤Ù¤­¤Ç¤¢¤ë¡£
-.TP
+\fBselect\fP()  から返った後には、全ての集合の全てのファイルディスクリプターについて 読み書き可能な状態になっているかをチェックすべきである。
+.TP 
 5.
-.\"O The functions
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O and
-.\"O .BR send (2)
-.\"O do \fInot\fP necessarily read/write the full amount of data
-.\"O that you have requested.
-.\"O If they do read/write the full amount, it's
-.\"O because you have a low traffic load and a fast stream.
-.\"O This is not always going to be the case.
-.\"O You should cope with the case of your
-.\"O functions only managing to send or receive a single byte.
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
-¤È¤¤¤Ã¤¿´Ø¿ô¤Ï¡¢¤³¤Á¤é¤¬Í׵ᤷ¤¿Á´¥Ç¡¼¥¿¤òÆɤ߽ñ¤­¤¹¤ëɬÍפÏ\fI¤Ê¤¤\fP¡£
-¤â¤·Á´¥Ç¡¼¥¿¤òÆɤ߽ñ¤­¤¹¤ë¤Ê¤é¡¢¤½¤ì¤Ï¥È¥é¥Õ¥£¥Ã¥¯¤ÎÉé²Ù¤¬¾®¤µ¤¯¡¢
-¥¹¥È¥ê¡¼¥à¤¬Â®¤¤¾ì¹ç¤À¤í¤¦¡£¤³¤Î¾ò·ï¤Ï¾ï¤ËËþ¤¿¤µ¤ì¤ë¤È¤Ï¸Â¤é¤Ê¤¤¡£
-¤³¤ì¤é¤Î´Ø¿ô¤¬´èÄ¥¤Ã¤Æ¤â 1 ¥Ð¥¤¥È¤·¤«Á÷¼õ¿®¤Ç¤­¤Ê¤¤¤è¤¦¤Ê¾ì¹ç¤â
-¹Íθ¤ËÆþ¤ì¤Æ¤ä¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
-.TP
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)
+といった関数は、こちらが要求した全データを読み書きする必要は\fIない\fP。 もし全データを読み書きするなら、それはトラフィックの負荷が小さく、
+ストリームが速い場合だろう。この条件は常に満たされるとは限らない。 これらの関数が頑張っても 1 バイトしか送受信できないような場合も
+考慮に入れてやらなければならない。
+.TP 
 6.
-.\"O Never read/write only in single bytes at a time unless you are really
-.\"O sure that you have a small amount of data to process.
-.\"O It is extremely
-.\"O inefficient not to read/write as much data as you can buffer each time.
-.\"O The buffers in the example below are 1024 bytes although they could
-.\"O easily be made larger.
-½èÍý¤¹¤ë¥Ç¡¼¥¿Î̤¬¾®¤µ¤¤¤³¤È¤¬¤Ï¤Ã¤­¤ê¤È¤ï¤«¤Ã¤Æ¤¤¤ë¾ì¹ç¤ò½ü¤¤¤Æ¡¢
-°ìÅ٤ˠ1 ¥Ð¥¤¥È¤º¤ÄÆɤ߽ñ¤­¤¹¤ë¤è¤¦¤Ê¤³¤È¤Ï¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
-¥Ð¥Ã¥Õ¥¡¤Îµö¤¹¤«¤®¤ê¤Î¥Ç¡¼¥¿¤ò¤Þ¤È¤á¤ÆÆɤ߽ñ¤­¤·¤Ê¤¤¤È¡¢
-Èó¾ï¤Ë¸úΨ¤¬°­¤¤¡£²¼µ­¤ÎÎã¤Ç¤Ï¥Ð¥Ã¥Õ¥¡¤Ï 1024 ¥Ð¥¤¥È¤Ë¤·¤Æ¤¤¤ë¤¬¡¢
-¤³¤Î¥µ¥¤¥º¤òÂ礭¤¯¤¹¤ë¤Î¤Ï´Êñ¤À¤í¤¦¡£
-.TP
+処理するデータ量が小さいことがはっきりとわかっている場合を除いて、 一度に 1 バイトずつ読み書きするようなことはしてはならない。
+バッファーの許すかぎりのデータをまとめて読み書きしないと、 非常に効率が悪い。下記の例ではバッファーは 1024 バイトにしているが、
+このサイズを大きくするのは簡単だろう。
+.TP 
 7.
-.\"O The functions
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O and
-.\"O .BR send (2)
-.\"O as well as the
-.\"O .BR select ()
-.\"O call can return \-1 with
-.\"O .I errno
-.\"O set to \fBEINTR\fP,
-.\"O or with
-.\"O .I errno
-.\"O set to \fBEAGAIN\fP (\fBEWOULDBLOCK\fP).
-.\"O These results must be properly managed (not done properly above).
-.\"O If your program is not going to receive any signals, then
-.\"O it is unlikely you will get \fBEINTR\fP.
-.\"O If your program does not set nonblocking I/O,
-.\"O you will not get \fBEAGAIN\fP.
-.\"O .\" Nonetheless, you should still cope with these errors for completeness.
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
-¤Ê¤É¤Î´Ø¿ô¤ä
-.BR select ()
-¥³¡¼¥ë¤Ï¡¢
-.I errno
-¤ò
-.B EINTR " ¤ä " EAGAIN
-.RB ( EWOULDBLOCK )
-¤Ë¤·¤Æ \-1 ¤òÊÖ¤¹¤³¤È¤¬¤¢¤ë¡£
-¤³¤Î¤è¤¦¤Ê·ë²Ì¤ËÂФ·¤ÆŬÀÚ¤ËÂбþ¤·¤Æ¤ä¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
-(¾åµ­¤ÎÎã¤Ç¤Ï¤·¤Æ¤¤¤Ê¤¤)¡£
-½ñ¤¤¤Æ¤¤¤ë¥×¥í¥°¥é¥à¤¬¥·¥°¥Ê¥ë¤ò¼õ¤±¤ëͽÄ꤬¤Ê¤±¤ì¤Ð¡¢
-.B EINTR
-¤¬ÊÖ¤µ¤ì¤ë¤³¤È¤Ï¤¢¤Þ¤ê¹Í¤¨¤é¤ì¤Ê¤¤¡£
-½ñ¤¤¤Æ¤¤¤ë¥×¥í¥°¥é¥à¤ÇÈó¥Ö¥í¥Ã¥¯ I/O ¤ò¥»¥Ã¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢
-.B EAGAIN
-¤¬ÊÖ¤µ¤ì¤ë¤³¤È¤Ï¤Ê¤¤¤À¤í¤¦¡£
-.\" ¤½¤ì¤Ç¤â¤Ê¤ª¡¢´°Á´¤ò´ü¤¹¤ë¤Ê¤é¤Ð¡¢
-.\" ¤³¤ì¤é¤Î¥¨¥é¡¼¤ò¹Íθ¤ËÆþ¤ì¤ëɬÍפ¬¤¢¤ë¡£
-.TP
+.\" Nonetheless, you should still cope with these errors for completeness.
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)  などの関数や \fBselect\fP()  コールは、
+\fIerrno\fP を \fBEINTR や EAGAIN\fP (\fBEWOULDBLOCK\fP)  にして \-1 を返すことがある。
+このような結果に対して適切に対応してやらなければならない (上記の例ではしていない)。 書いているプログラムがシグナルを受ける予定がなければ、
+\fBEINTR\fP が返されることはあまり考えられない。 書いているプログラムで非ブロック I/O をセットしていない場合は、 \fBEAGAIN\fP
+が返されることはないだろう。
+.TP 
 8.
-.\"O Never call
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O or
-.\"O .BR send (2)
-.\"O with a buffer length of zero.
-·è¤·¤Æ¡¢°ú¤­¿ô¤ËŤµ 0 ¤Î¥Ð¥Ã¥Õ¥¡¤ò»ØÄꤷ¤Æ
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
-¤ò¸Æ¤Ó½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
-.TP
+決して、引き数に長さ 0 のバッファーを指定して \fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)
+を呼び出してはならない。
+.TP 
 9.
-.\"O If the functions
-.\"O .BR read (2),
-.\"O .BR recv (2),
-.\"O .BR write (2),
-.\"O and
-.\"O .BR send (2)
-.\"O fail with errors other than those listed in \fB7.\fP,
-.\"O or one of the input functions returns 0, indicating end of file,
-.\"O then you should \fInot\fP pass that descriptor to
-.\"O .BR select ()
-.\"O again.
-.\"O In the example below,
-.\"O I close the descriptor immediately, and then set it to \-1
-.\"O to prevent it being included in a set.
-.BR read (2),
-.BR recv (2),
-.BR write (2),
-.BR send (2)
-¤¬
-\fB7.\fP ¤Ë¼¨¤·¤¿°Ê³°¤Î¥¨¥é¡¼¤Ç¼ºÇÔ¤·¤¿¾ì¹ç¤ä¡¢
-ÆþÎϷϤδؿô¤Î°ì¤Ä¤¬¥Õ¥¡¥¤¥ëËöÈø¤òɽ¤¹ 0 ¤òÊÖ¤·¤¿¾ì¹ç¤Ï¡¢
-¤½¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¤â¤¦°ìÅÙ select ¤ËÅϤ·¤Æ¤Ï\fI¤Ê¤é¤Ê¤¤\fP¡£
-²¼µ­¤ÎÎã¤Ç¤Ï¡¢¤½¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¤¿¤À¤Á¤Ë¥¯¥í¡¼¥º¤·¡¢
-¤½¤³¤Ë¤Ï \-1 ¤ò¥»¥Ã¥È¤·¤Æ¡¢
-¤½¤ì¤¬½¸¹ç¤Ë´Þ¤Þ¤ì³¤±¤ë¤Î¤òµö¤µ¤Ê¤¤¤è¤¦¤Ë¤·¤Æ¤¤¤ë¡£
-.TP
+\fBread\fP(2), \fBrecv\fP(2), \fBwrite\fP(2), \fBsend\fP(2)  が \fB7.\fP に示した以外のエラーで失敗した場合や、
+入力系の関数の一つがファイル末尾を表す 0 を返した場合は、 そのディスクリプターをもう一度 select に渡しては\fIならない\fP。
+下記の例では、そのディスクリプターをただちにクローズし、 そこには \-1 をセットして、 それが集合に含まれ続けるのを許さないようにしている。
+.TP 
 10.
-.\"O The timeout value must be initialized with each new call to
-.\"O .BR select (),
-.\"O since some operating systems modify the structure.
-.\"O .BR pselect ()
-.\"O however does not modify its timeout structure.
-¥¿¥¤¥à¥¢¥¦¥È¤ÎÃͤÏ
-.BR select ()
-¤ò¸Æ¤Ö¤¿¤Ó¤Ë½é´ü²½¤¹¤Ù¤­¤Ç¤¢¤ë¡£
-OS ¤Ë¤è¤Ã¤Æ¤Ï timeout ¹½Â¤ÂΤ¬Êѹ¹¤µ¤ì¤ë¾ì¹ç¤¬¤¢¤ë¤«¤é¤Ç¤¢¤ë¡£
-⤷¡¢
-.BR pselect ()
-¤Ï¼«Ê¬¤Î timeout ¹½Â¤ÂΤòÊѹ¹¤¹¤ë¤³¤È¤Ï¤Ê¤¤¡£
-.TP
+タイムアウトの値は \fBselect\fP()  を呼ぶたびに初期化すべきである。 OS によっては timeout
+構造体が変更される場合があるからである。 但し、 \fBpselect\fP()  は自分の timeout 構造体を変更することはない。
+.TP 
 11.
-.\"O Since
-.\"O .BR select ()
-.\"O modifies its file descriptor sets,
-.\"O if the call is being used in a loop,
-.\"O then the sets must be reinitialized before each call.
-.BR select ()
-¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿½¸¹ç¤òÊѹ¹¤¹¤ë¤Î¤Ç¡¢
-.BR select ()
-¤¬¥ë¡¼¥×¤ÎÃæ¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢¸Æ¤Ó½Ð¤·¤ò¹Ô¤¦Á°¤ËËè²ó
-¥Ç¥£¥¹¥¯¥ê¥×¥¿½¸¹ç¤ò½é´ü²½¤·Ä¾¤µ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
 .\" "I have heard" does not fill me with confidence, and doesn't
 .\" belong in a man page, so I've commented this point out.
 .\" .TP
-.\"O .\" 11.
-.\"O .\" I have heard that the Windows socket layer does not cope with OOB data
-.\"O .\" properly.
-.\"O .\" It also does not cope with
-.\"O .\" .BR select ()
-.\"O .\" calls when no file descriptors are set at all.
-.\"O .\" Having no file descriptors set is a useful
-.\"O .\" way to sleep the process with subsecond precision by using the timeout.
-.\"O .\" (See further on.)
-.\" Ê¹¤¤¤¿¤È¤³¤í¤Ç¤Ï¡¢Windows ¤Î¥½¥±¥Ã¥ÈÁؤÏ
-.\" OOB ¥Ç¡¼¥¿¤òÀµ¤·¤¯½èÍý¤·¤Ê¤¤¤é¤·¤¤¡£
-.\" ¤Þ¤¿¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Á´¤¯¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤è¤¦¤Ê
+.\" 11.
+.\" I have heard that the Windows socket layer does not cope with OOB data
+.\" properly.
+.\" It also does not cope with
 .\" .BR select ()
-.\" ¥³¡¼¥ë¤âÀµ¤·¤¯½èÍý¤·¤Ê¤¤¤é¤·¤¤¡£
-.\" ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò°ìÀÚÀßÄꤷ¤Ê¤¤¤Ç timeout ¤ò»È¤¦¤ä¤êÊý¤Ï¡¢
-.\" 1 Éðʲ¼¤ÎÀºÅÙ¤Ç¥×¥í¥»¥¹¤ò¥¹¥ê¡¼¥×¤µ¤»¤ë¤Ë¤ÏÊØÍø¤ÊÊýË¡¤Ê¤Î¤À¤¬
-.\" (³¤­¤ò¸«¤è)¡£
-.\"O .SS Usleep Emulation
-.SS usleep ¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó
-.\"O On systems that do not have a
-.\"O .BR usleep (3)
-.\"O function, you can call
-.\"O .BR select ()
-.\"O with a finite timeout and no file descriptors as
-.\"O follows:
-.BR usleep (3)
-´Ø¿ô¤ò»ý¤¿¤Ê¤¤¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
-Í­¸Â¤Î¥¿¥¤¥à¥¢¥¦¥È¤ò»ØÄꤷ¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÁ´¤¯¥»¥Ã¥È¤»¤º¤Ë
-.BR select ()
-¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¡¢¤³¤ì¤òÂåÍѤǤ­¤ë¡£
-°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë¡£
+.\" calls when no file descriptors are set at all.
+.\" Having no file descriptors set is a useful
+.\" way to sleep the process with subsecond precision by using the timeout.
+.\" (See further on.)
+\fBselect\fP()  はファイルディスクリプター集合を変更するので、 \fBselect\fP()
+がループの中で使用されている場合には、呼び出しを行う前に毎回 ディスクリプター集合を初期化し直さなければならない。
+.SS "usleep エミュレーション"
+\fBusleep\fP(3)  関数を持たないシステムでは、 有限のタイムアウトを指定し、ファイルディスクリプターを全くセットせずに \fBselect\fP()
+を呼び出すことで、これを代用できる。 以下のようにする。
 .PP
 .nf
     struct timeval tv;
@@ -777,105 +303,29 @@ OS 
     select(0, NULL, NULL, NULL, &tv);
 .fi
 .PP
-.\"O This is only guaranteed to work on UNIX systems, however.
-⤷¡¢¤³¤ì¤¬Æ°¤¯¤ÈÊݾڤµ¤ì¤Æ¤¤¤ë¤Î¤Ï UNIX ¥·¥¹¥Æ¥à¤Ë¸Â¤é¤ì¤ë¡£
-.\"O .SH RETURN VALUE
-.SH ÊÖ¤êÃÍ
-.\"O On success,
-.\"O .BR select ()
-.\"O returns the total number of file descriptors
-.\"O still present in the file descriptor sets.
-À®¸ù¤¹¤ë¤È¡¢
-.BR select ()
-¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿½¸¹ç¤Ë»Ä¤Ã¤Æ¤¤¤ë
-¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÁí¿ô¤òÊÖ¤¹¡£
-
-.\"O If
-.\"O .BR select ()
-.\"O timed out, then the return value will be zero.
-.\"O The file descriptors set should be all
-.\"O empty (but may not be on some systems).
-.BR select ()
-¤¬¥¿¥¤¥à¥¢¥¦¥È¤¹¤ë¤È¡¢ÊÖ¤êÃͤϠ0 ¤Ë¤Ê¤ë¡£
-¤½¤Î»þ¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿½¸¹ç¤Ï¤¹¤Ù¤Æ¶õ¤Ç¤¢¤ë
-(¤·¤«¤·¤½¤¦¤Ê¤é¤Ê¤¤¥·¥¹¥Æ¥à¤â¤¢¤ë)¡£
-
-.\"O A return value of \-1 indicates an error, with \fIerrno\fP being
-.\"O set appropriately.
-.\"O In the case of an error, the contents of the returned sets and
-.\"O the \fIstruct timeout\fP contents are undefined and should not be used.
-.\"O .BR pselect ()
-.\"O however never modifies \fIntimeout\fP.
-ÊÖ¤êÃͤ¬ \-1 ¤Î¾ì¹ç¤Ï¥¨¥é¡¼¤ò°ÕÌ£¤·¡¢
-.I errno
-¤¬Å¬Àڤ˥»¥Ã¥È¤µ¤ì¤ë¡£¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
-ÊÖ¤µ¤ì¤¿½¸¹ç¤ÎÆâÍƤ乽¤ÂΠ\fIstruct timeout\fP ¤ÎÆâÍƤÏ
-̤ÄêµÁ¤È¤Ê¤Ã¤Æ¤ª¤ê¡¢»ÈÍѤ¹¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£
-¤·¤«¤·
-.BR pselect ()
-¤Ï·è¤·¤Æ
-.I ntimeout
-¤òÊѹ¹¤·¤Ê¤¤¡£
-.\"O .SH NOTES
-.SH Ãí°Õ
-.\"O Generally speaking,
-.\"O all operating systems that support sockets also support
-.\"O .BR select ().
-.\"O .BR select ()
-.\"O can be used to solve
-.\"O many problems in a portable and efficient way that naive programmers try
-.\"O to solve in a more complicated manner using
-.\"O threads, forking, IPCs, signals, memory sharing, and so on.
-°ìÈÌŪ¤Ë¸À¤Ã¤Æ¡¢¥½¥±¥Ã¥È¤ò¥µ¥Ý¡¼¥È¤¹¤ëÁ´¤Æ¤Î¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¥·¥¹¥Æ¥à¤Ï
-.BR select ()
-¤â¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¡£
-.BR select ()
-¤ò»È¤¦¤È¡¢¥×¥í¥°¥é¥Þ¤¬¥¹¥ì¥Ã¥É¡¢¥Õ¥©¡¼¥¯¡¢IPC¡¢¥·¥°¥Ê¥ë¡¢¥á¥â¥ê¶¦Í­¡¢
-Åù¡¹¤ò»È¤Ã¤Æ¤â¤Ã¤ÈÊ£»¨¤ÊÊýË¡¤Ç²ò·è¤·¤è¤¦¤È¤¹¤ë¿¤¯¤ÎÌäÂ꤬¡¢
-°Ü¿¢À­¤¬¤¢¤ê¤«¤Ä¸úΨŪ¤ÊÊýË¡¤Ç²ò·è¤Ç¤­¤ë¡£
+但し、これが動くと保証されているのは UNIX システムに限られる。
+.SH 返り値
+成功すると、 \fBselect\fP()  はファイルディスクリプター集合に残っている ファイルディスクリプターの総数を返す。
+
+\fBselect\fP()  がタイムアウトすると、返り値は 0 になる。 その時、ファイルディスクリプター集合はすべて空である
+(しかしそうならないシステムもある)。
+
+返り値が \-1 の場合はエラーを意味し、 \fIerrno\fP が適切にセットされる。エラーが起こった場合、 返された集合の内容や構造体 \fIstruct
+timeout\fP の内容は 未定義となっており、使用すべきではない。 しかし \fBpselect\fP()  は決して \fIntimeout\fP
+を変更しない。
+.SH 注意
+一般的に言って、ソケットをサポートする全てのオペレーティングシステムは \fBselect\fP()  もサポートしている。 \fBselect\fP()
+を使うと、プログラマがスレッド、フォーク、IPC、シグナル、メモリー共有、 等々を使ってもっと複雑な方法で解決しようとする多くの問題が、
+移植性がありかつ効率的な方法で解決できる。
 .PP
-.\"O The
-.\"O .BR poll (2)
-.\"O system call has the same functionality as
-.\"O .BR select (),
-.\"O and is somewhat more efficient when monitoring sparse
-.\"O file descriptor sets.
-.\"O It is nowadays widely available, but historically was less portable than
-.\"O .BR select ().
-.BR poll (2)
-¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
-.BR select ()
-¤ÈƱ¤¸µ¡Ç½¤ò»ý¤Ã¤Æ¤ª¤ê¡¢
-¤Þ¤Ð¤é¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿½¸¹ç¤ò´Æ»ë¤¹¤ë¾ì¹ç¤Ë
-¤¤¤¯¤é¤«¸úΨ¤¬¤è¤¤¡£
-¸½ºß¤Ç¤Ï¹­¤¯ÍøÍѲÄǽ¤Ç¤¢¤ë¤¬¡¢°ÊÁ°¤Ï
-.BR select ()
-¤è¤ê°Ü¿¢À­¤ÎÌ̤ÇÎô¤Ã¤Æ¤¤¤¿¡£
+\fBpoll\fP(2)  システムコールは \fBselect\fP()  と同じ機能を持っており、 まばらなファイルディスクリプター集合を監視する場合に
+いくらか効率がよい。 現在では広く利用可能であるが、以前は \fBselect\fP()  より移植性の面で劣っていた。
 .PP
-.\"O The Linux-specific
-.\"O .BR epoll (7)
-.\"O API provides an interface that is more efficient than
-.\"O .BR select (2)
-.\"O and
-.\"O .BR poll (2)
-.\"O when monitoring large numbers of file descriptors.
-Linux Æȼ«¤Î
-.BR epoll (7)
-API ¤Ï¡¢Â¿¿ô¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò´Æ»ë¤¹¤ë¾ì¹ç¤Ë
-.BR select (2)
-¤ä
-.BR poll (2)
-¤è¤ê¤â¸úΨŪ¤Ê¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤òÄ󶡤·¤Æ¤¤¤ë¡£
-.\"O .SH EXAMPLE
-.SH Îã
-.\"O Here is an example that better demonstrates the true utility of
-.\"O .BR select ().
-.\"O The listing below a TCP forwarding program that forwards
-.\"O from one TCP port to another.
-.BR select ()
-¤ÎËÜÅö¤ËÊØÍø¤ÊÅÀ¤ò¼¨¤¹¡¢¤è¤¤Îã¤ò¾Ò²ð¤¹¤ë¡£
-°Ê²¼¤Î¥ê¥¹¥È¤Ï¡¢¤¢¤ë TCP ¥Ý¡¼¥È¤«¤éÊ̤Υݡ¼¥È¤ØžÁ÷¤ò¹Ô¤¦
-TCP ¥Õ¥©¥ï¡¼¥É¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£
+Linux 独自の \fBepoll\fP(7)  API は、多数のファイルディスクリプターを監視する場合に \fBselect\fP(2)  や
+\fBpoll\fP(2)  よりも効率的なインターフェースを提供している。
+.SH 例
+\fBselect\fP()  の本当に便利な点を示す、よい例を紹介する。 以下のリストは、ある TCP ポートから別のポートへ転送を行う TCP
+フォワードプログラムである。
 .PP
 .nf
 #include <stdlib.h>
@@ -908,7 +358,7 @@ listen_socket(int listen_port)
     }
     yes = 1;
     if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
-            (char *) &yes, sizeof(yes)) == \-1) {
+            &yes, sizeof(yes)) == \-1) {
         perror("setsockopt");
         close(s);
         return \-1;
@@ -921,7 +371,7 @@ listen_socket(int listen_port)
         close(s);
         return \-1;
     }
-    printf("accepting connections on port %d\\n", listen_port);
+    printf("accepting connections on port %d\en", listen_port);
     listen(s, 10);
     return s;
 }
@@ -932,7 +382,8 @@ connect_socket(int connect_port, char *address)
     struct sockaddr_in a;
     int s;
 
-    if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
+    s = socket(AF_INET, SOCK_STREAM, 0);
+    if (s == \-1) {
         perror("socket");
         close(s);
         return \-1;
@@ -957,20 +408,20 @@ connect_socket(int connect_port, char *address)
     return s;
 }
 
-#define SHUT_FD1 do {                                \\
-                     if (fd1 >= 0) {                 \\
-                         shutdown(fd1, SHUT_RDWR);   \\
-                         close(fd1);                 \\
-                         fd1 = \-1;                   \\
-                     }                               \\
+#define SHUT_FD1 do {                                \e
+                     if (fd1 >= 0) {                 \e
+                         shutdown(fd1, SHUT_RDWR);   \e
+                         close(fd1);                 \e
+                         fd1 = \-1;                   \e
+                     }                               \e
                  } while (0)
 
-#define SHUT_FD2 do {                                \\
-                     if (fd2 >= 0) {                 \\
-                         shutdown(fd2, SHUT_RDWR);   \\
-                         close(fd2);                 \\
-                         fd2 = \-1;                   \\
-                     }                               \\
+#define SHUT_FD2 do {                                \e
+                     if (fd2 >= 0) {                 \e
+                         shutdown(fd2, SHUT_RDWR);   \e
+                         close(fd2);                 \e
+                         fd2 = \-1;                   \e
+                     }                               \e
                  } while (0)
 
 #define BUF_SIZE 1024
@@ -985,8 +436,8 @@ main(int argc, char *argv[])
     int buf2_avail, buf2_written;
 
     if (argc != 4) {
-        fprintf(stderr, "Usage\\n\\tfwd <listen-port> "
-                 "<forward-to-port> <forward-to-ip-address>\\n");
+        fprintf(stderr, "Usage\en\etfwd <listen\-port> "
+                 "<forward\-to\-port> <forward\-to\-ip\-address>\en");
         exit(EXIT_FAILURE);
     }
 
@@ -1060,7 +511,7 @@ main(int argc, char *argv[])
                 if (fd2 == \-1)
                     SHUT_FD1;
                 else
-                    printf("connect from %s\\n",
+                    printf("connect from %s\en",
                             inet_ntoa(client_address.sin_addr));
             }
         }
@@ -1143,57 +594,22 @@ main(int argc, char *argv[])
 }
 .fi
 .PP
-.\"O The above program properly forwards most kinds of TCP connections
-.\"O including OOB signal data transmitted by \fBtelnet\fP servers.
-.\"O It handles the tricky problem of having data flow in both directions
-.\"O simultaneously.
-.\"O You might think it more efficient to use a
-.\"O .BR fork (2)
-.\"O call and devote a thread to each stream.
-.\"O This becomes more tricky than you might suspect.
-.\"O Another idea is to set nonblocking I/O using
-.\"O .BR fcntl (2).
-.\"O This also has its problems because you end up using
-.\"O inefficient timeouts.
-¾åµ­¤Î¥×¥í¥°¥é¥à¤Ï¡¢¤Û¤È¤ó¤É¤Î¼ïÎà¤Î TCP Àܳ¤ò¥Õ¥©¥ï¡¼¥É¤¹¤ë¡£
-.B telnet
-¥µ¡¼¥Ð¤Ë¤è¤Ã¤ÆÃæ·Ñ¤µ¤ì¤ë OOB ¥·¥°¥Ê¥ë¥Ç¡¼¥¿¤â°·¤¨¤ë¡£
-¤³¤Î¥×¥í¥°¥é¥à¤Ï¡¢¥Ç¡¼¥¿¥Õ¥í¡¼¤òÁÐÊý¸þ¤ËƱ»þ¤ËÁ÷¤ë¤È¤¤¤¦¡¢
-¤ä¤ä¤³¤·¤¤ÌäÂê¤â½èÍý¤Ç¤­¤ë¡£
-.BR fork (2)
-¥³¡¼¥ë¤ò»È¤Ã¤Æ¡¢³Æ¥¹¥È¥ê¡¼¥à¤´¤È¤ËÀìÍѤΥ¹¥ì¥Ã¥É¤òÍѤ¤¤ë¤Û¤¦¤¬¸úΨŪ¤À¡¢
-¤È¤¤¤¦¿Í¤â¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£¤·¤«¤·¡¢¤³¤ì¤Ï¹Í¤¨¤Æ¤¤¤ë¤è¤ê¤º¤Ã¤È¤ä¤ä¤³¤·¤¤¡£
-¤¢¤ë¤¤¤Ï¡¢
-.BR fcntl (2)
-¤ò»È¤Ã¤ÆÈó¥Ö¥í¥Ã¥¯ I/O ¤ò¥»¥Ã¥È¤¹¤ì¤ÐÎɤ¤¡¢¤È¤¤¤¦¥¢¥¤¥Ç¥¢¤â¤¢¤ë¤À¤í¤¦¡£
-¤³¤ì¤Ë¤â¼ÂºÝ¤Ë¤ÏÌäÂ꤬¤¢¤ê¡¢¥¿¥¤¥à¥¢¥¦¥È¤¬Èó¸úΨŪ¤Ëµ¯¤³¤Ã¤Æ¤·¤Þ¤¦¡£
-
-.\"O The program does not handle more than one simultaneous connection at a
-.\"O time, although it could easily be extended to do this with a linked list
-.\"O of buffers\(emone for each connection.
-.\"O At the moment, new
-.\"O connections cause the current connection to be dropped.
-¤³¤Î¥×¥í¥°¥é¥à¤Ï°ìÅ٤ˤҤȤİʾå¤ÎƱ»þÀܳ¤ò°·¤¦¤³¤È¤Ï¤Ç¤­¤Ê¤¤¤¬¡¢
-¤½¤ÎÍͤ˳ÈÄ¥¤¹¤ë¤Î¤Ï´Êñ¤Ç¡¢¥Ð¥Ã¥Õ¥¡¤Î¥ê¥ó¥¯¥ê¥¹¥È¤ò
-(Àܳ¤´¤È¤Ë¤Ò¤È¤Ä¤º¤Ä) »È¤¨¤Ð¤è¤¤¡£
-¸½»þÅÀ¤Î¤â¤Î¤Ç¤Ï¡¢¿·¤·¤¤Àܳ¤¬¤¯¤ë¤È¸Å¤¤Àܳ¤ÏÍî¤Á¤Æ¤·¤Þ¤¦¡£
-.\"O .SH SEE ALSO
-.SH ´ØÏ¢¹àÌÜ
-.BR accept (2),
-.BR connect (2),
-.BR ioctl (2),
-.BR poll (2),
-.BR read (2),
-.BR recv (2),
-.BR select (2),
-.BR send (2),
-.BR sigprocmask (2),
-.BR write (2),
-.BR sigaddset (3),
-.BR sigdelset (3),
-.BR sigemptyset (3),
-.BR sigfillset (3),
-.BR sigismember (3),
-.BR epoll (7)
+上記のプログラムは、ほとんどの種類の TCP 接続をフォワードする。 \fBtelnet\fP サーバによって中継される OOB シグナルデータも扱える。
+このプログラムは、データフローを双方向に同時に送るという、 ややこしい問題も処理できる。 \fBfork\fP(2)
+コールを使って、各ストリームごとに専用のスレッドを用いるほうが効率的だ、 という人もいるかもしれない。しかし、これは考えているよりずっとややこしい。
+あるいは、 \fBfcntl\fP(2)  を使って非ブロック I/O をセットすれば良い、というアイデアもあるだろう。
+これにも実際には問題があり、タイムアウトが非効率的に起こってしまう。
+
+このプログラムは一度にひとつ以上の同時接続を扱うことはできないが、 その様に拡張するのは簡単で、バッファーのリンクリストを (接続ごとにひとつずつ)
+使えばよい。 現時点のものでは、新しい接続がくると古い接続は落ちてしまう。
+.SH 関連項目
 .\" .SH AUTHORS
 .\" This man page was written by Paul Sheer.
+\fBaccept\fP(2), \fBconnect\fP(2), \fBioctl\fP(2), \fBpoll\fP(2), \fBread\fP(2),
+\fBrecv\fP(2), \fBselect\fP(2), \fBsend\fP(2), \fBsigprocmask\fP(2), \fBwrite\fP(2),
+\fBsigaddset\fP(3), \fBsigdelset\fP(3), \fBsigemptyset\fP(3), \fBsigfillset\fP(3),
+\fBsigismember\fP(3), \fBepoll\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。