OSDN Git Service

(split) LDP_man-pages: release ioctl.2 [JM:00378]
[linuxjm/LDP_man-pages.git] / draft / man3 / strerror.3
1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2005, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" References consulted:
25 .\"     Linux libc source code
26 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\"     386BSD man pages
28 .\" Modified Sat Jul 24 18:05:30 1993 by Rik Faith <faith@cs.unc.edu>
29 .\" Modified Fri Feb 16 14:25:17 1996 by Andries Brouwer <aeb@cwi.nl>
30 .\" Modified Sun Jul 21 20:55:44 1996 by Andries Brouwer <aeb@cwi.nl>
31 .\" Modified Mon Oct 15 21:16:25 2001 by John Levon <moz@compsoc.man.ac.uk>
32 .\" Modified Tue Oct 16 00:04:43 2001 by Andries Brouwer <aeb@cwi.nl>
33 .\" Modified Fri Jun 20 03:04:30 2003 by Andries Brouwer <aeb@cwi.nl>
34 .\" 2005-12-13, mtk, Substantial rewrite of strerror_r() description
35 .\"         Addition of extra material on portability and standards.
36 .\"
37 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
38 .\"       all rights reserved.
39 .\" Translated 1997-01-20, YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
40 .\" Updated & Modified 2001-11-03, Yuichi SATO <ysato@h4.dion.ne.jp>
41 .\" Updated 2005-12-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
42 .\" Updated 2007-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.64
43 .\"
44 .\"WORD         GNU-specific            GNU »ÅÍͤÎ
45 .\"WORD         XSI-compliant           XSI ½àµò¤Î
46 .\"
47 .TH STRERROR 3  2009-03-30 "" "Linux Programmer's Manual"
48 .\"O .SH NAME
49 .SH Ì¾Á°
50 .\"O strerror, strerror_r \- return string describing error number
51 strerror, strerror_r \- ¥¨¥é¡¼ÈÖ¹æ¤òÀâÌÀ¤¹¤ëʸ»úÎó¤òÊÖ¤¹¡£
52 .\"O .SH SYNOPSIS
53 .SH ½ñ¼°
54 .nf
55 .B #include <string.h>
56 .sp
57 .BI "char *strerror(int " errnum );
58 .sp
59 .BI "char *strerror_r(int " errnum ", char *" buf ", size_t " buflen );
60 .fi
61 .sp
62 .in -4n
63 .\"O Feature Test Macro Requirements for glibc (see
64 .\"O .BR feature_test_macros (7)):
65 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
66 .RB ( feature_test_macros (7)
67 »²¾È):
68 .in
69 .sp
70 .\"O The XSI-compliant version of
71 .\"O .BR strerror_r ()
72 .\"O is provided if:
73 ¼¡¤Î¾ì¹ç¤Ë¤Ï
74 XSI ½àµò¤Î¥Ð¡¼¥¸¥ç¥ó¤Î
75 .BR strerror_r ()
76 ¤¬Ä󶡤µ¤ì¤ë:
77 .br
78 (_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) && !\ _GNU_SOURCE
79 .fi
80 .\"O .SH DESCRIPTION
81 .\"O The
82 .\"O .BR strerror ()
83 .\"O function returns a pointer to a string that describes the error
84 .\"O code passed in the argument \fIerrnum\fP, possibly using the
85 .\"O .B LC_MESSAGES
86 .\"O part of the current locale to select the appropriate language.
87 .\"O This string must not be modified by the application, but may be
88 .\"O modified by a subsequent call to \fBperror\fP(3) or
89 .\"O .BR strerror ().
90 .\"O No library function will modify this string.
91 .SH ÀâÌÀ
92 .BR strerror ()
93 ´Ø¿ô¤Ï¡¢°ú¤­¿ô \fIerrnum\fP ¤ÇÅϤµ¤ì¤¿¥¨¥é¡¼¥³¡¼¥É¤Ë¤Ä¤¤¤Æ¤Î
94 ÀâÌÀ¤¬Æþ¤Ã¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
95 ²Äǽ¤Ç¤¢¤ë¤Ê¤é¤Ð¡¢Å¬ÀڤʸÀ¸ì¤òÁªÂò¤¹¤ë¤¿¤á¤Ë¡¢
96 ¸½ºß¤Î¥í¥±¡¼¥ë¤Î
97 .B LC_MESSAGES
98 ¤ò»È¤¦¡£
99 ¤³¤Îʸ»úÎó¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÇÊѹ¹¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¤¬¡¢
100 ¤½¤Î¸å¤Ëµ¯¤³¤ë
101 .BR perror (3)
102 ¤ä
103 .BR strerror ()
104 ¤Î¸Æ¤Ó½Ð¤·¤Ç
105 Êѹ¹¤µ¤ì¤Æ¤â¹½¤ï¤Ê¤¤¡£
106 ¤³¤Îʸ»úÎó¤òÊѹ¹¤¹¤ë¥é¥¤¥Ö¥é¥ê´Ø¿ô¤Ï¤Ê¤¤¡£
107
108 .\"O The
109 .\"O .BR strerror_r ()
110 .\"O function is similar to
111 .\"O .BR strerror (),
112 .\"O but is
113 .\"O thread safe.
114 .\"O This function is available in two versions:
115 .\"O an XSI-compliant version specified in POSIX.1-2001
116 .\"O (available since glibc 2.3.4),
117 .\"O and a GNU-specific version (available since glibc 2.0).
118 .\"O The XSI-compliant version is provided with the feature test macros
119 .\"O settings shown in the SYNOPSIS;
120 .\"O otherwise the GNU-specific version is provided.
121 .BR strerror_r ()
122 ´Ø¿ô¤Ï
123 .BR strerror ()
124 ¤È»÷¤Æ¤¤¤ë¤¬¡¢
125 ¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¤¢¤ë¡£
126 ¤³¤Î´Ø¿ô¤Ë¤ÏÆó¼ïÎà¤Î¥Ð¡¼¥¸¥ç¥ó¤¬Â¸ºß¤·¡¢
127 POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤¿ XSI ½àµò¤Î¥Ð¡¼¥¸¥ç¥ó
128 (glibc 2.3.4 °Ê¹ß¤ÇÍøÍѲÄǽ) ¤È¡¢
129 GNU »ÅÍͤΥС¼¥¸¥ç¥ó (glibc 2.0 °Ê¹ß¤ÇÍøÍѲÄǽ) ¤Ç¤¢¤ë¡£
130 ¡Ö½ñ¼°¡×¤ÎÀá¤Ëµ­ºÜ¤µ¤ì¤¿µ¡Ç½¸¡ºº¥Þ¥¯¥í¤Î¾ì¹ç¤Ë¤Ï¡¢
131 XSI ½àµò¤Î¥Ð¡¼¥¸¥ç¥ó¤¬Ä󶡤µ¤ì¤ë¡£
132 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï GNU »ÅÍͤΥС¼¥¸¥ç¥ó¤¬Ä󶡤µ¤ì¤ë¡£
133 .\"O If no feature test macros are explicitly defined,
134 .\"O then (since glibc 2.4)
135 .\"O .B _POSIX_SOURCE
136 .\"O is defined by default with the value
137 .\"O 200112L, so that the XSI-compliant version of
138 .\"O .BR strerror_r ()
139 .\"O is provided by default.
140 µ¡Ç½¸¡ºº¥Þ¥¯¥í¤¬°ì¤Ä¤âÌÀ¼¨Åª¤ËÄêµÁ¤µ¤ì¤Ê¤¤¾ì¹ç¡¢
141 (glibc 2.4 °Ê¹ß¤Ç¤Ï) ¥Ç¥Õ¥©¥ë¥È¤Ç
142 .B _POSIX_SOURCE
143 ¤ÏÃÍ 200112l ¤ÇÄêµÁ¤µ¤ì¡¢¤½¤Î·ë²Ì
144 XSI ½àµò¤Î¥Ð¡¼¥¸¥ç¥ó¤Î
145 .BR strerror_r ()
146 ¤¬¥Ç¥Õ¥©¥ë¥È¤ÇÄ󶡤µ¤ì¤ë¡£
147
148 .\"O The XSI-compliant
149 .\"O .BR strerror_r ()
150 .\"O is preferred for portable applications.
151 .\"O It returns the error string in the user-supplied buffer
152 .\"O .I buf
153 .\"O of length
154 .\"O .IR buflen .
155 °Ü¿¢À­¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢
156 XSI ½àµò¤Î
157 .BR strerror_r ()
158 ¤ò»È¤¦Êý¤¬¤è¤¤¡£
159 ¤³¤Î´Ø¿ô¤Ï¡¢¥æ¡¼¥¶¡¼¤«¤éÄ󶡤µ¤ì¤ëŤµ
160 .I buflen
161 ¤Î¥Ð¥Ã¥Õ¥¡
162 .I buf
163 ¤Ë¥¨¥é¡¼Ê¸»úÎó¤òÊÖ¤¹¡£
164
165 .\"O The GNU-specific
166 .\"O .BR strerror_r ()
167 .\"O returns a pointer to a string containing the error message.
168 .\"O This may be either a pointer to a string that the function stores in
169 .\"O .IR buf ,
170 .\"O or a pointer to some (immutable) static string
171 .\"O (in which case
172 .\"O .I buf
173 .\"O is unused).
174 .\"O If the function stores a string in
175 .\"O .IR buf ,
176 .\"O then at most
177 .\"O .I buflen
178 .\"O bytes are stored (the string may be truncated if
179 .\"O .I buflen
180 .\"O is too small) and the string always includes a terminating null byte.
181 GNU »ÅÍͤÎ
182 .BR strerror_r ()
183 ¤Ï¡¢¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò³ÊǼ¤·¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
184 ÊÖ¤êÃͤϡ¢¤³¤Î´Ø¿ô¤¬
185 .I buf
186 ¤Ë³ÊǼ¤·¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤«¡¢
187 ²¿¤é¤«¤Î (ÉÔÊѤÊ) ÀÅŪ¤Êʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¡¢¤Î¤¤¤º¤ì¤«¤È¤Ê¤ë
188 (¸å¼Ô¤Î¾ì¹ç¤Ï
189 .I buf
190 ¤Ï»ÈÍѤµ¤ì¤Ê¤¤)¡£
191 .I buf
192 ¤Ëʸ»úÎ󤬳ÊǼ¤µ¤ì¤ë¾ì¹ç¤Ï¡¢
193 ºÇÂç¤Ç
194 .I buflen
195 ¥Ð¥¤¥È¤¬³ÊǼ¤µ¤ì
196 .RI ( buflen
197 ¤¬¾®¤µ²á¤®¤¿¤È¤­¤Ë¤Ïʸ»úÎó¤ÏÀÚ¤êµÍ¤á¤é¤ì¤ë)¡¢
198 ʸ»úÎó¤Ë¤Ïɬ¤º½ªÃ¼¥Ì¥ëʸ»ú¤¬´Þ¤Þ¤ì¤ë¡£
199 .\"O .SH "RETURN VALUE"
200 .SH ÊÖ¤êÃÍ
201 .\"O The
202 .\"O .BR strerror ()
203 .\"O and
204 .\"O .BR strerror_r ()
205 .\"O functions return
206 .\"O the appropriate error description string,
207 .\"O or an "Unknown error nnn" message if the error number is unknown.
208 .BR strerror ()
209 ¤È
210 .BR strerror_r ()
211 ¤Ï¥¨¥é¡¼ÆâÍƤòÀâÌÀ¤¹¤ë
212 ʸ»úÎó¤òÊÖ¤¹¡£¥¨¥é¡¼Èֹ椬̤ÃΤξì¹ç¤Ï "Unknown error nnn" ¤È¤¤¤¦
213 ¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹¡£
214
215 .\"O The XSI-compliant
216 .\"O .BR strerror_r ()
217 .\"O function returns 0 on success;
218 .\"O on error, \-1 is returned and
219 .\"O .I errno
220 .\"O is set to indicate the error.
221 XSI ½àµò¤Î
222 .BR strerror_r ()
223 ´Ø¿ô¤ÏÀ®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤¹¡£
224 ¥¨¥é¡¼¤Î¾ì¹ç¤Ë¤Ï¡¢ \-1 ¤òÊÖ¤·¡¢
225 .I errno
226 ¤Ë¥¨¥é¡¼ÆâÍƤò¼¨¤¹Ãͤò¥»¥Ã¥È¤¹¤ë¡£
227 .\"O .SH ERRORS
228 .SH ¥¨¥é¡¼
229 .TP
230 .B EINVAL
231 .\"O The value of
232 .\"O .I errnum
233 .\"O is not a valid error number.
234 .I errnum
235 ¤ÎÃͤ¬Í­¸ú¤Ê¥¨¥é¡¼ÈÖ¹æ¤Ç¤Ï¤Ê¤¤¡£
236 .TP
237 .B ERANGE
238 .\"O Insufficient storage was supplied to contain the error description string.
239 ¥¨¥é¡¼¥³¡¼¥É¤òÀâÌÀ¤¹¤ëʸ»úÎó¤Î¤¿¤á¤Ë¡¢½¼Ê¬¤ÊÎΰ褬³ÎÊݤǤ­¤Ê¤«¤Ã¤¿¡£
240 .\"O .SH "CONFORMING TO"
241 .SH ½àµò
242 .\"O .BR strerror ()
243 .\"O is specified by POSIX.1-2001, C89, C99.
244 .\"O .BR strerror_r ()
245 .\"O is specified by POSIX.1-2001.
246 .BR strerror ()
247 ¤Ï POSIX.1-2001, C89, C99 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
248 .BR strerror_r ()
249 ¤Ï POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
250
251 .\"O The GNU-specific
252 .\"O .BR strerror_r ()
253 .\"O function is a nonstandard extension.
254 GNU »ÅÍͤÎ
255 .BR strerror_r ()
256 ´Ø¿ô¤ÏÈóɸ½à¤Î³ÈÄ¥¤Ç¤¢¤ë¡£
257
258 .\"O POSIX.1-2001 permits
259 .\"O .BR strerror ()
260 .\"O to set
261 .\"O .I errno
262 .\"O if the call encounters an error, but does not specify what
263 .\"O value should be returned as the function result in the event of an error.
264 .\"O On some systems,
265 .\"O .\" e.g., Solaris 8, HP-UX 11
266 .\"O .BR strerror ()
267 .\"O returns NULL if the error number is unknown.
268 .\"O On other systems,
269 .\"O .\" e.g., FreeBSD 5.4, Tru64 5.1B
270 .\"O .BR strerror ()
271 .\"O returns a string something like "Error nnn occurred" and sets
272 .\"O .I errno
273 .\"O to
274 .\"O .B EINVAL
275 .\"O if the error number is unknown.
276 POSIX.1-2001 ¤Ï¡¢
277 .BR strerror ()
278 ¤¬¥¨¥é¡¼¤ËÁø¶ø¤·¤¿¾ì¹ç¤Ë
279 .I errno
280 ¤ò¥»¥Ã¥È¤¹¤ë¤³¤È¤òǧ¤á¤Æ¤¤¤ë¤¬¡¢¥¨¥é¡¼È¯À¸»þ¤Ë´Ø¿ô¤Î·ë²Ì¤È¤·¤Æ
281 ¤É¤ó¤ÊÃͤòÊÖ¤¹¤Ù¤­¤«¤òµ¬Äꤷ¤Æ¤Ê¤¤¡£
282 ¤¢¤ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
283 .\" Î㤨¤Ð Solaris 8, HP-UX 11
284 ¥¨¥é¡¼Èֹ椬̤ÃΤξì¹ç¡¢
285 .BR strerror ()
286 ¤Ï NULL ¤òÊÖ¤¹¡£
287 ¾¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
288 .\" Î㤨¤Ð FreeBSD 5.4, Tru64 5.1B
289 ¥¨¥é¡¼Èֹ椬̤ÃΤξì¹ç¡¢
290 .BR strerror ()
291 ¤Ï "Error nnn occurred" ¤È¤¤¤Ã¤¿Ê¸»úÎó¤òÊÖ¤·¡¢
292 .I errno
293 ¤Ë
294 .B EINVAL
295 ¤ò¥»¥Ã¥È¤¹¤ë¡£
296 .\"O .SH "SEE ALSO"
297 .SH ´ØÏ¢¹àÌÜ
298 .BR err (3),
299 .BR errno (3),
300 .BR error (3),
301 .BR perror (3),
302 .BR strsignal (3)