.\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk) .\" and Copyright (C) 2005, 2014 Michael Kerrisk .\" .\" %%%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. .\" .\" 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. .\" %%%LICENSE_END .\" .\" 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. .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" 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 .\" Updated 2012-05-02, Akihiro MOTOKI .\" Updated 2013-07-22, Akihiro MOTOKI .\" .TH STRERROR 3 2014\-03\-18 "" "Linux Programmer's Manual" .SH 名前 strerror, strerror_r, strerror_l \- エラー番号を説明する文字列を返す。 .SH 書式 .nf \fB#include \fP .sp \fBchar *strerror(int \fP\fIerrnum\fP\fB);\fP .sp \fBint strerror_r(int \fP\fIerrnum\fP\fB, char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB);\fP /* XSI\-compliant */ .sp \fBchar *strerror_r(int \fP\fIerrnum\fP\fB, char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB);\fP /* GNU\-specific */ \fBchar *strerror_l(int \fP\fIerrnum\fP\fB, locale_t \fP\fIlocale\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .ad l .sp \fBstrerror_r\fP(): .RS 4 次の場合には XSI 準拠のバージョンが提供される: .br (_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) && !\ _GNU_SOURCE .br それ以外の場合、GNU バージョンが提供される。 .RE .ad .SH 説明 .\" \fBstrerror\fP() 関数は、引き数 \fIerrnum\fP で渡されたエラーコードについての説明が入った文字列へのポインタを返す。 可能であるならば、適切な言語を選択するために、 現在のロケールの \fBLC_MESSAGES\fP を使う。(例えば、 \fIerrnum\fP が \fBEINVAL\fP の場合、説明として "Invalid argument" が返される。) この文字列は、アプリケーションで変更してはならないが、 これ以降に行われる \fBstrerror\fP() や \fBstrerror_l\fP() の呼び出しで変更されても構わない。 \fBperror\fP(3) などの、これ以外のライブラリ関数ではこの文字列は変更されない。 .SS strerror_r() \fBstrerror_r\fP() 関数は \fBstrerror\fP() と似ているが、スレッドセーフである。 この関数には二種類のバージョンが存在し、 POSIX.1\-2001 で規定された XSI 準拠のバージョン (glibc 2.3.4 以降で利用可能だが、glibc 2.13 までは POSIX 準拠ではない) と、 GNU 仕様のバージョン (glibc 2.0 以降で利用可能) である。 「書式」の節に記載された機能検査マクロの場合には、 XSI 準拠の バージョンが提供される。それ以外の場合には GNU 仕様のバージョンが提供さ れる。機能検査マクロが一つも明示的に定義されない場合、 (glibc 2.4 以降 では) デフォルトで \fB_POSIX_SOURCE\fP は値 200112l で定義され、その結果 XSI 準拠のバージョンの \fBstrerror_r\fP() がデフォルトで提供される。 移植性が必要なアプリケーションでは、 XSI 準拠の \fBstrerror_r\fP() を使う方がよい。 この関数は、ユーザーから提供される長さ \fIbuflen\fP のバッファ \fIbuf\fP にエラー文字列を返す。 .\" GNU 仕様の \fBstrerror_r\fP() は、 エラーメッセージを格納した文字列へのポインタを返す。 返り値は、 この関数が \fIbuf\fP に格納した文字列へのポインタか、 何らかの (不変な) 静的な文字列へのポインタ、 のいずれかとなる (後者の場合は \fIbuf\fP は使用されない)。 \fIbuf\fP に文字列が格納される場合は、 最大で \fIbuflen\fP バイトが格納される (\fIbuflen\fP が小さ過ぎたときには文字列は切り詰められ、 \fIerrnum\fP は不定である)。 文字列には必ず終端ヌル文字 (\(aq\e0\(aq) が含まれる。 .SS strerror_l() \fBstrerror_l\fP() は \fBstrerror\fP() と同様だが、 \fIerrnum\fP を \fIlocale\fP で指定されたロケールのロケール依存のエラーメッセージにマッピングする。 \fIlocale\fP が特別なロケールオブジェクト \fBLC_GLOBAL_LOCALE\fP の場合、もしくは \fIlocale\fP が有効なロケールオブジェクトハンドルでない場合は、 \fBstrerror_l\fP() の動作は未定義である。 .SH 返り値 関数 \fBstrerror\fP(), \fBstrerror_l\fP() と GNU 固有の関数 \fBstrerror_r\fP() はエラー内容を説明する文字列を返す。 エラー番号が未知の場合は "Unknown error nnn" という メッセージを返す。 XSI 準拠の \fBstrerror_r\fP() 関数は成功すると 0 を返す。エラーの場合には、 (glibc 2.13 以降では) (正の) エラー番号が返され、(バージョン 2.13 より前 の glibc では) \-1 が返され、 \fIerrno\fP にエラーを示す値がセットされる。 POSIX.1\-2001 と POSIX.1\-2008 では、 \fBstrerror\fP() や \fBstrerror_l\fP() が成功した場合は \fIerrno\fP を変更せずに元のままにしなければならないとされている。関数のどの返り値もエラーを示すために予約されていないので、エラーをチェックしたいアプリケーションは呼び出しを行う前に \fIerrno\fP を 0 に初期化し、呼び出しの後で \fIerrno\fP をチェックすべき点に注意すること。 .SH エラー .TP \fBEINVAL\fP \fIerrnum\fP の値が有効なエラー番号ではない。 .TP \fBERANGE\fP エラーコードを説明する文字列のために、充分な領域が確保できなかった。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" \fBstrerror\fP() 関数はスレッドセーフではない。 .LP .\" FIXME Need a thread-safety statement about strerror_l() \fBstrerror_r\fP() 関数はスレッドセーフである。 .SH バージョン \fBstrerror_l\fP() 関数は glibc 2.6 で初めて登場した。 .SH 準拠 \fBstrerror\fP() は POSIX.1\-2001, POSIX.1\-2008, C89, C99 で規定されている。 \fBstrerror_r\fP() は POSIX.1\-2001 と POSIX.1\-2008 で規定されている。 \fBstrerror_l\fP() は POSIX.1\-2008 で規定されている。 GNU 仕様の \fBstrerror_r\fP() 関数は非標準の拡張である。 .\" e.g., Solaris 8, HP-UX 11 .\" e.g., FreeBSD 5.4, Tru64 5.1B POSIX.1\-2001 は、 \fBstrerror\fP() がエラーに遭遇した場合に \fIerrno\fP をセッ トすることを認めているが、エラー発生時に関数の結果として どんな値を返す べきかを規定してない。 あるシステムでは、 エラー番号が未知の場合、 \fBstrerror\fP() は NULL を返す。 他のシステムでは、 エラー番号が未知の場 合、 \fBstrerror\fP() は "Error nnn occurred" といった文字列を返し、 \fIerrno\fP に \fBEINVAL\fP をセットする。 C99 と POSIX.1\-2008 では、返り値が NULL 以外になることが求められている。 .SH 関連項目 \fBerr\fP(3), \fBerrno\fP(3), \fBerror\fP(3), \fBperror\fP(3), \fBstrsignal\fP(3), \fBlocale\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。