OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / man3 / perror.3
1 .\" Copyright (c) 1994 Michael Haardt (michael@moria.de), 1994-06-04
2 .\" Copyright (c) 1995 Michael Haardt
3 .\"      (michael@cantor.informatik.rwth-aachen.de), 1995-03-16
4 .\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl), 1996-01-13
5 .\"
6 .\" This is free documentation; you can redistribute it and/or
7 .\" modify it under the terms of the GNU General Public License as
8 .\" published by the Free Software Foundation; either version 2 of
9 .\" the License, or (at your option) any later version.
10 .\"
11 .\" The GNU General Public License's references to "object code"
12 .\" and "executables" are to be interpreted as the output of any
13 .\" document formatting or typesetting system, including
14 .\" intermediate and printed output.
15 .\"
16 .\" This manual is distributed in the hope that it will be useful,
17 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 .\" GNU General Public License for more details.
20 .\"
21 .\" You should have received a copy of the GNU General Public
22 .\" License along with this manual; if not, write to the Free
23 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
24 .\" USA.
25 .\"
26 .\" 1996-01-13 aeb: merged in some text contributed by Melvin Smith
27 .\"   (msmith@falcon.mercer.peachnet.edu) and various other changes.
28 .\" Modified 1996-05-16 by Martin Schulze (joey@infodrom.north.de)
29 .\"
30 .\"*******************************************************************
31 .\"
32 .\" This file was generated with po4a. Translate the source file.
33 .\"
34 .\"*******************************************************************
35 .TH PERROR 3 2012\-04\-17 "" "Linux Programmer's Manual"
36 .SH 名前
37 perror \- システムエラーメッセージを出力する
38 .SH 書式
39 \fB#include <stdio.h>\fP
40 .sp
41 \fBvoid perror(const char *\fP\fIs\fP\fB);\fP
42 .sp
43 \fB#include <errno.h>\fP
44 .sp
45 \fBconst char *\fP\fIsys_errlist\fP\fB[];\fP
46 .br
47 \fBint \fP\fIsys_nerr\fP\fB;\fP
48 .br
49 \fBint \fP\fIerrno\fP\fB;\fP
50 .sp
51 .in -4n
52 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
53 .in
54 .sp
55 \fIsys_errlist\fP, \fIsys_nerr\fP: _BSD_SOURCE
56 .SH 説明
57 関数 \fBperror\fP()  は、システムコールやライブラリ関数の呼び出しにおいて、最後に発生した
58 エラーに関する説明メッセージを生成し、標準エラー出力に出力する。 (\fIs\fP が NULL でなく、 \fI*s\fP が NULL バイト
59 (\(aq\e0\(aq) でない場合には) 引き数の文字列 \fIs\fP がまず出力され、続いてコロン、空白が出力され、
60 それからメッセージと改行が出力される。
61
62 このメッセージを最大限活用するためには、引き数文字列にエラーが発生した 関数名を入れておくとよい。 エラー番号は外部変数 \fIerrno\fP
63 から取得される。 \fIerrno\fP はエラーが発生した時に設定され、 成功した呼び出しではクリアされない。
64
65 大域変数のエラーリスト \fIsys_errlist\fP[] は \fIerrno\fP を添字とする配列で、この
66 配列から改行無しのエラーメッセージが取得される。 テーブルでの最大のメッセージ
67 番号は \fIsys_nerr\fP \-1 となる。 このテーブルを直接参照する際には注意すること。
68 なぜなら、新しいエラー番号が \fIsys_errlist\fP[] に追加済とは限らないからである。
69 現在では、\fIsys_errlist\fP[] の使用は非推奨となっている。
70
71
72 システムコールが失敗した場合、通常、返り値として \-1 が返り、 \fIerrno\fP にエラーを識別する値が設定される (設定されるエラー番号は
73 \fI<errno.h>\fP に記載されている)。 多くのライブラリ関数も同様の動作となる。 関数 \fBperror\fP()
74 は、このエラーコードの可読なメッセージへの変換を行う。 \fIerrno\fP は、ライブラリ呼び出しが成功した後には未定義であることに注意が必要である:
75 その呼び出し自身は成功したとしても、内部で呼び出した他のライブラリ関数が 失敗して、その結果をこの変数に設定することがあるからだ。
76 よって、失敗した呼び出しの直後に \fBperror\fP()  を呼ばない場合には \fIerrno\fP の値を 保存しておかなければならない。
77 .SH 準拠
78 関数 \fBperror\fP()  と外部変数 \fIerrno\fP (\fBerrno\fP(3)  参照) は C89, 4.3BSD, POSIX.1\-2001
79 に準拠している。 外部変数 \fIsys_nerr\fP と \fIsys_errlist\fP は BSD に準拠している。
80 .SH 注意
81 .\" and only when _BSD_SOURCE is defined.
82 .\" When
83 .\" .B _GNU_SOURCE
84 .\" is defined, the symbols
85 .\" .I _sys_nerr
86 .\" and
87 .\" .I _sys_errlist
88 .\" are provided.
89 外部変数 \fIsys_nerr\fP と \fIsys_errlist\fP は glibc で定義されているが、 \fI<stdio.h>\fP
90 に含まれている。
91 .SH 関連項目
92 \fBerr\fP(3), \fBerrno\fP(3), \fBerror\fP(3), \fBstrerror\fP(3)