OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man2 / read.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\"                               1993 Michael Haardt, Ian Jackson.
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" Modified Sat Jul 24 00:06:00 1993 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified Wed Jan 17 16:02:32 1996 by Michael Haardt
28 .\"   <michael@cantor.informatik.rwth-aachen.de>
29 .\" Modified Thu Apr 11 19:26:35 1996 by Andries Brouwer <aeb@cwi.nl>
30 .\" Modified Sun Jul 21 18:59:33 1996 by Andries Brouwer <aeb@cwi.nl>
31 .\" Modified Fri Jan 31 16:47:33 1997 by Eric S. Raymond <esr@thyrsus.com>
32 .\" Modified Sat Jul 12 20:45:39 1997 by Michael Haardt
33 .\"   <michael@cantor.informatik.rwth-aachen.de>
34 .\"
35 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
36 .\"         all rights reserved.
37 .\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
38 .\" Modified 1997-09-28, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
39 .\" Updated & Modified 2005-02-24, Yuichi SATO <ysato444@yahoo.co.jp>
40 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
41 .\" Updated 2005-10-14, Akihiro MOTOKI
42 .\" Updated 2008-02-10, Akihiro MOTOKI, LDP v2.77
43 .\" Updated 2009-04-13, Akihiro MOTOKI, LDP v3.20
44 .\"
45 .\"WORD:        descriptor              ¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
46 .\"WORD:        buffer                  ¥Ð¥Ã¥Õ¥¡¡¼
47 .\"WORD:        signal                  ¥·¥°¥Ê¥ë
48 .\"WORD:        process group           ¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×
49 .\"WORD:        backgraound             ¥Ð¥Ã¥¯¥°¥é¥ó¥É
50 .\"WORD:        orphan                  ¸ÉΩ
51 .\"WORD:        open                    ¥ª¡¼¥×¥ó
52 .\"WORD:        directory               ¥Ç¥£¥ì¥¯¥È¥ê
53 .\"WORD:        object                  ¥ª¥Ö¥¸¥§¥¯¥È
54 .\"
55 .TH READ 2 2009-02-23 "Linux" "Linux Programmer's Manual"
56 .SH Ì¾Á°
57 read \- ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤«¤éÆɤ߹þ¤à
58 .SH ½ñ¼°
59 .nf
60 .B #include <unistd.h>
61 .sp
62 .BI "ssize_t read(int " fd ", void *" buf ", size_t " count );
63 .fi
64 .SH ÀâÌÀ
65 .BR read ()
66 ¤Ï¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ (file descriptor)
67 .I fd
68 ¤«¤éºÇÂç
69 .I count
70 ¥Ð¥¤¥È¤ò
71 .I buf
72 ¤Ç»Ï¤Þ¤ë¥Ð¥Ã¥Õ¥¡¡¼¤ØÆɤ߹þ¤â¤¦¤È¤¹¤ë¡£
73 .PP
74 .I count
75 ¤¬ 0 ¤Ê¤é¤Ð¡¢
76 .BR read ()
77 ¤Ï 0 ¤òÊÖ¤·¡¢Â¾¤Ë²¿¤âµ¯¤­¤Ê¤¤¡£
78 .I count
79 ¤¬
80 .B SSIZE_MAX
81 ¤è¤êÂ礭¤±¤ì¤Ð¡¢·ë²Ì¤ÏÆÃÄê¤Ç¤­¤Ê¤¤¡£
82 .SH ÊÖ¤êÃÍ
83 À®¸ù¤·¤¿¾ì¹ç¡¢Æɤ߹þ¤ó¤À¥Ð¥¤¥È¿ô¤òÊÖ¤¹ (0 ¤Ï¥Õ¥¡¥¤¥ë¤Î½ª¤ê¤ò°ÕÌ£¤¹¤ë)¡£
84 ¥Õ¥¡¥¤¥ë°ÌÃ֤Ϥ³¤Î¿ô¤À¤±¿Ê¤á¤é¤ì¤ë¡£
85 ¤³¤Î¿ô¤¬Í׵ᤷ¤¿¿ô¤è¤ê¾®¤µ¤«¤Ã¤¿¤È¤·¤Æ¤â¥¨¥é¡¼¤Ç¤Ï¤Ê¤¤;
86 Î㤨¤Ðº£¤¹¤°¤Ë¤Ï¼ÂºÝ¤Ë¤½¤ì¤À¤±¤Î¿ô¤·¤«¤Ê¤¤¾ì¹ç (¥Õ¥¡¥¤¥ë¤ÎºÇ¸å¤Ë¶á¤¤¤Î¤«¤â
87 ¤·¤ì¤Ê¤¤¤·¡¢¥Ñ¥¤¥× (pipe) ¤äüËö (terminal) ¤«¤éÆɤ߹þ¤ó¤Ç¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤) ¤ä
88 .BR read ()
89 ¤¬¥·¥°¥Ê¥ë (signal) ¤Ë¤è¤Ã¤Æ³ä¤ê¹þ¤Þ¤ì¤¿¾ì¹ç¤Ë¤³¤ì¤Ïµ¯¤³¤ê¤¨¤ë¡£
90 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï¡¢\-1 ¤¬ÊÖ¤µ¤ì¡¢
91 .I errno
92 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£¤³¤Î¾ì¹ç¤Ï¥Õ¥¡¥¤¥ë°ÌÃÖ¤¬Êѹ¹¤µ¤ì¤ë¤«¤É¤¦¤«¤Ï
93 ÉÔÄê¤Ç¤¢¤ë¡£
94 .SH ¥¨¥é¡¼
95 .TP
96 .B EAGAIN
97 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
98 .I fd
99 ¤¬¥½¥±¥Ã¥È°Ê³°¤Î¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¤¤Æ¡¢
100 ÈóÄä»ß (nonblocking) ¥â¡¼¥É
101 .RB ( O_NONBLOCK )
102 ¤ËÀßÄꤵ¤ì¤Æ¤ª¤ê¡¢Æɤ߹þ¤ß¤ò¹Ô¤¦¤ÈÄä»ß¤¹¤ë¾õ¶·¤Ë¤¢¤ë¡£
103 .TP
104 .BR EAGAIN " ¤Þ¤¿¤Ï " EWOULDBLOCK
105 .\" Actually EAGAIN on Linux
106 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
107 .I fd
108 ¤¬¥½¥±¥Ã¥È¤ò»²¾È¤·¤Æ¤¤¤Æ¡¢ÈóÄä»ß (nonblocking) ¥â¡¼¥É
109 .RB ( O_NONBLOCK )
110 ¤ËÀßÄꤵ¤ì¤Æ¤ª¤ê¡¢Æɤ߹þ¤ß¤ò¹Ô¤¦¤ÈÄä»ß¤¹¤ë¾õ¶·¤Ë¤¢¤ë¡£
111 POSIX.1-2001 ¤Ï¡¢¤³¤Î¾ì¹ç¤Ë¤É¤Á¤é¤Î¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤âǧ¤á¤Æ¤ª¤ê¡¢
112 ¤³¤ì¤é 2 ¤Ä¤ÎÄê¿ô¤¬Æ±¤¸Ãͤò»ý¤Ä¤³¤È¤âµá¤á¤Æ¤¤¤Ê¤¤¡£
113 ¤·¤¿¤¬¤Ã¤Æ¡¢°Ü¿¢À­¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢Î¾Êý¤Î²ÄǽÀ­¤ò
114 ³Îǧ¤¹¤Ù¤­¤Ç¤¢¤ë¡£
115 .TP
116 .B EBADF
117 .I fd
118 ¤¬Í­¸ú¤Ê¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤Ç¤Ê¤¤¤«¡¢Æɤ߹þ¤ß¤Î¤¿¤á¤Ë
119 ¥ª¡¼¥×¥ó (open) ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
120 .TP
121 .B EFAULT
122 .I buf
123 ¤¬¥¢¥¯¥»¥¹²Äǽ¤Ê¥¢¥É¥ì¥¹¶õ´Ö¤Î³°¤Ë¤¢¤ë¡£
124 .TP
125 .B EINTR
126 ²¿¤Î¥Ç¡¼¥¿¤âÆɤ߹þ¤Þ¤Ê¤¤¤¦¤Á¤Ë¥·¥°¥Ê¥ë¤Ë³ä¤ê¹þ¤Þ¤ì¤¿¡£
127 .BR signal (7)
128 »²¾È¡£
129 .TP
130 .B EINVAL
131 .I fd
132 ¤ÏÆɤ߹þ¤ß¤ËŬ¤·¤Æ¤¤¤Ê¤¤¥ª¥Ö¥¸¥§¥¯¥È¤ò»²¾È¤·¤Æ¤¤¤ë¡£
133 ¤â¤·¤¯¤Ï¡¢¥Õ¥¡¥¤¥ë¤¬
134 .B O_DIRECT
135 ¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¤¬¡¢
136 .I buf
137 ¤Ë»ØÄꤵ¤ì¤¿¥¢¥É¥ì¥¹¡¢
138 .I count
139 ¤Ë»ØÄꤵ¤ì¤¿ÃÍ¡¢
140 ¸½ºß¤Î¥Õ¥¡¥¤¥ë¥ª¥Õ¥»¥Ã¥È¤Î¤¤¤º¤ì¤«¤Î
141 ¥¢¥é¥¤¥ó¥á¥ó¥È¤¬ÉÔŬÀڤǤ¢¤ë¡£
142 .TP
143 .B EINVAL
144 .I fd
145 ¤¬
146 .BR timerfd_create (2)
147 ¤Î¸Æ¤Ó½Ð¤·¤ÇºîÀ®¤µ¤ì¤¿¤¬¡¢
148 .BR read ()
149 ¤Ë´Ö°ã¤Ã¤¿¥µ¥¤¥º¤Î¥Ð¥Ã¥Õ¥¡¤¬ÅϤµ¤ì¤¿¡£
150 ¤µ¤é¤Ê¤ë¾ðÊó¤Ï
151 .BR timerfd_create (2)
152 ¤ò»²¾È¤Î¤³¤È¡£
153 .TP
154 .B EIO
155 I/O ¥¨¥é¡¼¡£¤³¤ì¤ÏÎ㤨¤Ð¥×¥í¥»¥¹¤¬¥Ð¥Ã¥¯¥°¥é¥ó¥É¡¦¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¤Ç¡¢
156 ¤½¤ì¤òÀ©¸æ¤·¤Æ¤¤¤ë tty ¤«¤éÆɤ߹þ¤â¤¦¤È¤·¡¢
157 .B SIGTTIN
158 ¤¬Ìµ»ë (ignore) ¤Þ¤¿¤Ï¶Ø»ß (blocking) ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤ä¡¢
159 ¤½¤Î¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¤¬¸ÉΩ (orphan) ¤·¤Æ¤¤¤ë¾ì¹ç¤Ëµ¯¤³¤ë¡£
160 ¤Þ¤¿¥Ç¥£¥¹¥¯¤ä¥Æ¡¼¥×¤òÆɤó¤Ç¤¤¤ë»þ¤ËÄã¥ì¥Ù¥ë I/O ¥¨¥é¡¼
161 ¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤âµ¯¤³¤ë¡£
162 .TP
163 .B EISDIR
164 .I fd
165 ¤¬¥Ç¥£¥ì¥¯¥È¥ê¤ò»²¾È¤·¤Æ¤¤¤ë¡£
166 .PP
167 .I fd
168 ¤¬Àܳ¤·¤Æ¤¤¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤è¤Ã¤Æ¤Ï¾¤Î¥¨¥é¡¼¤âµ¯¤³¤ê¤¨¤ë¡£
169 POSIX ¤Ç¤Ï¡¢
170 ¤¤¤¯¤é¤«¤Î¥Ç¡¼¥¿¤òÆɤó¤À¸å¤Ë³ä¤ê¹þ¤ß¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
171 .BR read ()
172 ¤Ï
173 .RI ( errno
174 ¤Ë
175 .B EINTR
176 ¤òÀßÄꤷ¤Æ) \-1 ¤òÊÖ¤·¤Æ¤â¤è¤¤¤·¡¢
177 ´û¤ËÆɤ߹þ¤ó¤À¥Ð¥¤¥È¿ô¤òÊÖ¤·¤Æ¤â¤è¤¤¡£
178 .SH ½àµò
179 SVr4, 4.3BSD, POSIX.1-2001.
180 .SH Ãí°Õ
181 NFS ¤Ë¤ª¤¤¤Æ¡£¾¯Î̤Υǡ¼¥¿¤òÆɤ߹þ¤à¾ì¹ç¡¢ºÇ½é¤Î»þ¤Î¤ß¤Ë¥¿¥¤¥à
182 ¥¹¥¿¥ó¥×¤¬¹¹¿·¤µ¤ì¡¢Â³¤¯¥³¡¼¥ë¤Ç¤Ï¹¹¿·¤µ¤ì¤Ê¤¤¤À¤í¤¦¡£
183 ¤³¤ì¤Ï¥¯¥é¥¤¥¢¥ó¥È¦¤Ç°À­¤Î¥­¥ã¥Ã¥·¥ó¥°¤ò¹Ô¤Ê¤¦¤¿¤á¤Ç¤¢¤ë¡£
184 ¤Ê¤¼¤Ê¤é¤Ð¡¢¤â¤·Á´¤Æ¤Î NFS ¥¯¥é¥¤¥¢¥ó¥È¤¬ st_atime (ºÇ½ª¥Õ¥¡¥¤¥ë¥¢¥¯¥»¥¹»þ¹ï)
185 ¤Î¹¹¿·¤ò¥µ¡¼¥Ð¡¼¤ËÁ÷¤é¤º¡¢¥¯¥é¥¤¥¢¥ó¥È¦¤Ç¥­¥ã¥Ã¥·¥å¤òÆɤळ¤È¤ËËþ­¤·¤Æ
186 ¤¤¤ì¤Ð¡¢¥µ¡¼¥Ð¡¼Â¦¤Ç¤Î read ¤ÏȯÀ¸¤·¤Ê¤¤¤Î¤Ç st_atime ¤Î¹¹¿·¤Ï¹Ô¤Ê¤ï¤ì¤«¤é¤À¡£
187 Unix ¤ÎÊý¼°¤Ç¤Ï¡¢¥¯¥é¥¤¥¢¥ó¥È¦¤Î°À­¤Î¥­¥ã¥Ã¥·¥ó¥°¤ò̵¸ú¤Ë¤¹¤ë¤³¤È¤Ç¡¢
188 ¤³¤ì¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£¤·¤«¤·¤Û¤È¤ó¤É¤Î¾õ¶·¤Ç¤Ï¤³¤ì¤Ï³¤¯¥µ¡¼¥Ð¡¼¤Î
189 Éé²Ù¤òÁý²Ã¤µ¤»¡¢¥Ñ¥Õ¥©¡¼¥Þ¥ó¥¹¤ÎÄã²¼¤ò¤â¤¿¤é¤¹¡£
190 .PP
191 ¿¤¯¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ä¥Ç¥£¥¹¥¯¤Ï
192 .B O_NONBLOCK
193 ¤Î¼ÂÁõ¤Ï¤·¤Ê¤¯¤Æ¤âºÑ¤à¤¯¤é¤¤¤Ë½½Ê¬¤Ë¹â®¤Ç¤¢¤ë¤È¹Í¤¨¤é¤ì¤Æ¤¤¤ë¡£
194 ¤½¤ì¤Ç¤½¤Î¤è¤¦¤Ê¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥¹¥¯¤Ë¤Ï
195 .B O_NONBLOCK
196 ¤ÏÍøÍѤǤ­¤Ê¤¤¤«¤â¤·¤ì¤Ê¤¤¡£
197 .SH ´ØÏ¢¹àÌÜ
198 .BR close (2),
199 .BR fcntl (2),
200 .BR ioctl (2),
201 .BR lseek (2),
202 .BR open (2),
203 .BR pread (2),
204 .BR readdir (2),
205 .BR readlink (2),
206 .BR readv (2),
207 .BR select (2),
208 .BR write (2),
209 .BR fread (3)