.\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk) .\" and Copyright (C) 2005, Michael Kerrisk .\" .\" 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. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sat Jul 24 18:05:30 1993 by Rik Faith .\" Modified Fri Feb 16 14:25:17 1996 by Andries Brouwer .\" Modified Sun Jul 21 20:55:44 1996 by Andries Brouwer .\" Modified Mon Oct 15 21:16:25 2001 by John Levon .\" Modified Tue Oct 16 00:04:43 2001 by Andries Brouwer .\" Modified Fri Jun 20 03:04:30 2003 by Andries Brouwer .\" 2005-12-13, mtk, Substantial rewrite of strerror_r() description .\" Addition of extra material on portability and standards. .\" .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi .\" all rights reserved. .\" Translated 1997-01-20, YOSHINO Takashi .\" Updated & Modified 2001-11-03, Yuichi SATO .\" Updated 2005-12-26, Akihiro MOTOKI .\" Updated 2007-09-06, Akihiro MOTOKI , LDP v2.64 .\" .\"WORD GNU-specific GNU 仕様の .\"WORD XSI-compliant XSI 準拠の .\" .TH STRERROR 3 2009-03-30 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O strerror, strerror_r \- return string describing error number strerror, strerror_r \- エラー番号を説明する文字列を返す。 .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "char *strerror(int " errnum ); .sp .BI "char *strerror_r(int " errnum ", char *" buf ", size_t " buflen ); .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .\"O The XSI-compliant version of .\"O .BR strerror_r () .\"O is provided if: 次の場合には XSI 準拠のバージョンの .BR strerror_r () が提供される: .br (_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) && !\ _GNU_SOURCE .fi .\"O .SH DESCRIPTION .\"O The .\"O .BR strerror () .\"O function returns a pointer to a string that describes the error .\"O code passed in the argument \fIerrnum\fP, possibly using the .\"O .B LC_MESSAGES .\"O part of the current locale to select the appropriate language. .\"O This string must not be modified by the application, but may be .\"O modified by a subsequent call to \fBperror\fP(3) or .\"O .BR strerror (). .\"O No library function will modify this string. .SH 説明 .BR strerror () 関数は、引き数 \fIerrnum\fP で渡されたエラーコードについての 説明が入った文字列へのポインタを返す。 可能であるならば、適切な言語を選択するために、 現在のロケールの .B LC_MESSAGES を使う。 この文字列は、アプリケーションで変更してはならないが、 その後に起こる .BR perror (3) や .BR strerror () の呼び出しで 変更されても構わない。 この文字列を変更するライブラリ関数はない。 .\"O The .\"O .BR strerror_r () .\"O function is similar to .\"O .BR strerror (), .\"O but is .\"O thread safe. .\"O This function is available in two versions: .\"O an XSI-compliant version specified in POSIX.1-2001 .\"O (available since glibc 2.3.4), .\"O and a GNU-specific version (available since glibc 2.0). .\"O The XSI-compliant version is provided with the feature test macros .\"O settings shown in the SYNOPSIS; .\"O otherwise the GNU-specific version is provided. .BR strerror_r () 関数は .BR strerror () と似ているが、 スレッドセーフである。 この関数には二種類のバージョンが存在し、 POSIX.1-2001 で規定された XSI 準拠のバージョン (glibc 2.3.4 以降で利用可能) と、 GNU 仕様のバージョン (glibc 2.0 以降で利用可能) である。 「書式」の節に記載された機能検査マクロの場合には、 XSI 準拠のバージョンが提供される。 それ以外の場合には GNU 仕様のバージョンが提供される。 .\"O If no feature test macros are explicitly defined, .\"O then (since glibc 2.4) .\"O .B _POSIX_SOURCE .\"O is defined by default with the value .\"O 200112L, so that the XSI-compliant version of .\"O .BR strerror_r () .\"O is provided by default. 機能検査マクロが一つも明示的に定義されない場合、 (glibc 2.4 以降では) デフォルトで .B _POSIX_SOURCE は値 200112l で定義され、その結果 XSI 準拠のバージョンの .BR strerror_r () がデフォルトで提供される。 .\"O The XSI-compliant .\"O .BR strerror_r () .\"O is preferred for portable applications. .\"O It returns the error string in the user-supplied buffer .\"O .I buf .\"O of length .\"O .IR buflen . 移植性が必要なアプリケーションでは、 XSI 準拠の .BR strerror_r () を使う方がよい。 この関数は、ユーザーから提供される長さ .I buflen のバッファ .I buf にエラー文字列を返す。 .\"O The GNU-specific .\"O .BR strerror_r () .\"O returns a pointer to a string containing the error message. .\"O This may be either a pointer to a string that the function stores in .\"O .IR buf , .\"O or a pointer to some (immutable) static string .\"O (in which case .\"O .I buf .\"O is unused). .\"O If the function stores a string in .\"O .IR buf , .\"O then at most .\"O .I buflen .\"O bytes are stored (the string may be truncated if .\"O .I buflen .\"O is too small) and the string always includes a terminating null byte. GNU 仕様の .BR strerror_r () は、エラーメッセージを格納した文字列へのポインタを返す。 返り値は、この関数が .I buf に格納した文字列へのポインタか、 何らかの (不変な) 静的な文字列へのポインタ、のいずれかとなる (後者の場合は .I buf は使用されない)。 .I buf に文字列が格納される場合は、 最大で .I buflen バイトが格納され .RI ( buflen が小さ過ぎたときには文字列は切り詰められる)、 文字列には必ず終端ヌル文字が含まれる。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR strerror () .\"O and .\"O .BR strerror_r () .\"O functions return .\"O the appropriate error description string, .\"O or an "Unknown error nnn" message if the error number is unknown. .BR strerror () と .BR strerror_r () はエラー内容を説明する 文字列を返す。エラー番号が未知の場合は "Unknown error nnn" という メッセージを返す。 .\"O The XSI-compliant .\"O .BR strerror_r () .\"O function returns 0 on success; .\"O on error, \-1 is returned and .\"O .I errno .\"O is set to indicate the error. XSI 準拠の .BR strerror_r () 関数は成功すると 0 を返す。 エラーの場合には、 \-1 を返し、 .I errno にエラー内容を示す値をセットする。 .\"O .SH ERRORS .SH エラー .TP .B EINVAL .\"O The value of .\"O .I errnum .\"O is not a valid error number. .I errnum の値が有効なエラー番号ではない。 .TP .B ERANGE .\"O Insufficient storage was supplied to contain the error description string. エラーコードを説明する文字列のために、充分な領域が確保できなかった。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O .BR strerror () .\"O is specified by POSIX.1-2001, C89, C99. .\"O .BR strerror_r () .\"O is specified by POSIX.1-2001. .BR strerror () は POSIX.1-2001, C89, C99 で規定されている。 .BR strerror_r () は POSIX.1-2001 で規定されている。 .\"O The GNU-specific .\"O .BR strerror_r () .\"O function is a nonstandard extension. GNU 仕様の .BR strerror_r () 関数は非標準の拡張である。 .\"O POSIX.1-2001 permits .\"O .BR strerror () .\"O to set .\"O .I errno .\"O if the call encounters an error, but does not specify what .\"O value should be returned as the function result in the event of an error. .\"O On some systems, .\"O .\" e.g., Solaris 8, HP-UX 11 .\"O .BR strerror () .\"O returns NULL if the error number is unknown. .\"O On other systems, .\"O .\" e.g., FreeBSD 5.4, Tru64 5.1B .\"O .BR strerror () .\"O returns a string something like "Error nnn occurred" and sets .\"O .I errno .\"O to .\"O .B EINVAL .\"O if the error number is unknown. POSIX.1-2001 は、 .BR strerror () がエラーに遭遇した場合に .I errno をセットすることを認めているが、エラー発生時に関数の結果として どんな値を返すべきかを規定してない。 あるシステムでは、 .\" 例えば Solaris 8, HP-UX 11 エラー番号が未知の場合、 .BR strerror () は NULL を返す。 他のシステムでは、 .\" 例えば FreeBSD 5.4, Tru64 5.1B エラー番号が未知の場合、 .BR strerror () は "Error nnn occurred" といった文字列を返し、 .I errno に .B EINVAL をセットする。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR err (3), .BR errno (3), .BR error (3), .BR perror (3), .BR strsignal (3)