.\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl) .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" 5 Oct 2002, Modified by Michael Kerrisk .\" Updated for POSIX.1 2001 .\" 2004-12-17 Martin Schulze , mtk .\" Removed errno declaration prototype, added notes .\" 2006-02-09 Kurt Wall, mtk .\" Added non-POSIX errors .\" .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka .\" all rights reserved. .\" Translated 1997-12-24, HIROFUMI Nishizuka .\" Updated 1999-03-01, NAKANO Takeo .\" Updated 1999-08-21, NAKANO Takeo .\" Updated 2003-07-03, Akihiro MOTOKI .\" Updated 2005-03-15, Akihiro MOTOKI .\" Updated 2006-02-15, Akihiro MOTOKI, Catch up to LDP v2.23 .\" Updated 2006-07-14, Akihiro MOTOKI, Catch up to LDP v2.34 .\" Updated 2008-08-07, Akihiro MOTOKI, Catch up to LDP v3.05 .\" .TH ERRNO 3 2008-07-09 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O errno \- number of last error errno \- 直近に発生したエラーの番号 .\"O .SH SYNOPSIS .SH 書式 .B #include .\".sp .\".BI "extern int " errno ; .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .I .\"O header file defines the integer variable .\"O .IR errno , .\"O which is set by system calls and some library functions in the event .\"O of an error to indicate what went wrong. .\"O Its value is significant only when the return value of .\"O the call indicated an error .\"O (i.e., \-1 from most system calls; .\"O \-1 or NULL from most library functions); .\"O a function that succeeds .\"O .I is .\"O allowed to change .\"O .IR errno . ヘッダファイル .I で整数型の変数 .I errno が定義されており、 システムコールやいくつかのライブラリ関数は、エラーが発生した際に この変数にその原因を示す値を設定する。 この値は呼び出しの返り値がエラー (ほとんどのシステムコールでは \-1 で、ほとんどのライブラリ関数では \-1 か NULL) を示したときに のみ意味を持つが、ライブラリ関数は成功した場合も .I errno を変更することが許されている。 .\"O Valid error numbers are all nonzero; \fIerrno\fP is never set to zero .\"O by any system call or library function. 有効なエラー番号はいずれも 0 以外の値を持つ。 どのシステムコールもライブラリ関数も \fIerrno\fP を 0 に設定することはない。 .\"O For some system calls and library functions (e.g., .\"O .BR getpriority (2)), .\"O \-1 is a valid return on success. .\"O In such cases, a successful return can be distinguished from an error .\"O return by setting .\"O .I errno .\"O to zero before the call, and then, .\"O if the call returns a status that indicates that an error .\"O may have occurred, checking to see if .\"O .I errno .\"O has a nonzero value. いくつかのシステムコールやライブラリ関数 (例えば .BR getpriority (2)) では、成功した場合の有効な返り値として \-1 が返されることがある。 このような場合、成功なのかエラーなのかを区別するためには、 呼び出しの前に .I errno を 0 に設定しておけばよい。呼び出しの返り値がエラー発生の可能性を 示すものだった場合には、 .I errno が 0 以外の値かを見て確認すればよい。 .\"O \fIerrno\fP is defined by the ISO C standard to be a modifiable lvalue .\"O of type \fIint\fP, and must not be explicitly declared; \fIerrno\fP .\"O may be a macro. .\"O \fIerrno\fP is thread-local; setting it in one thread .\"O does not affect its value in any other thread. \fIerrno\fP は、ISO C standard で \fIint\fP 型の変更可能な左辺値 として定義されており、明示的に宣言を行ってはならない; \fIerrno\fP はマクロの場合もありえる。 \fIerrno\fP はスレッド毎に値を持つ。 つまりあるスレッドで \fIerrno\fP が設定されても、 他のスレッドの \fIerrno\fP には影響しない。 .\"O All the error names specified by POSIX.1 .\"O must have distinct values, with the exception of .\"O .B EAGAIN .\"O and .\"O .BR EWOULDBLOCK , .\"O which may be the same. POSIX.1 で定義されているすべてのエラー名には、 それぞれ異なる値が対応していなければならない。 但し、 .B EAGAIN と .B EWOULDBLOCK は例外で、これらは同じ値を持ってもよい。 .\" The following is now .\"O .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of .\"O .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C .\"O .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for .\"O .\" coding errors in multibyte or wide characters. .\" POSIX.1 (2001 年版) でのエラー名シンボルのリストを以下に示す。 .\" これらのうち、 \fBEDOM\fP と \fBERANGE\fP は ISO C standard にある。 .\" さらに、ISO C Amendment 1 では、エラー番号 \fBEILSEQ\fP が .\" マルチバイト文字やワイド文字での符号化エラーを表すために .\" 定義されている。 .\" .\"O Below is a list of the symbolic error names that are defined on Linux. .\"O Some of these are marked .\"O .IR POSIX.1 , .\"O indicating that the name is defined by POSIX.1-2001, or .\"O .IR C99 , .\"O indicating that the name is defined by C99. .TP 16 .B E2BIG .\"O Argument list too long (POSIX.1) 引き数リストが長過ぎる (POSIX.1) .TP .B EACCES .\"O Permission denied (POSIX.1) 許可がない (POSIX.1) .TP .B EADDRINUSE .\"O Address already in use (POSIX.1) アドレスがすでに使用されている (POSIX.1) .TP .B EADDRNOTAVAIL .\"O Address not available (POSIX.1) アドレスが使用できない (POSIX.1) .\"O .\" EADV is only an error on HURD(?) .\" EADV は HURD においてだけのエラー(?) .TP .B EAFNOSUPPORT .\"O Address family not supported (POSIX.1) アドレス・ファミリーがサポートされていない (POSIX.1) .TP .B EAGAIN .\"O Resource temporarily unavailable (may be the same value as .\"O .BR EWOULDBLOCK ) .\"O (POSIX.1) リソースが一時的に利用不可 .RB ( EWOULDBLOCK と同じ値でもよい) (POSIX.1) .TP .B EALREADY .\"O Connection already in progress (POSIX.1) 接続が既に処理中である (POSIX.1) .TP .B EBADE .\"O Invalid exchange 不正なやり取り (exchange) である .TP .B EBADF .\"O Bad file descriptor (POSIX.1) ファイルディスクリプタが不正である (POSIX.1) .TP .B EBADFD .\"O File descriptor in bad state ファイルディスクリプタが不正な状態である .TP .B EBADMSG .\"O Bad message (POSIX.1) メッセージが不正である (POSIX.1) .TP .B EBADR .\"O Invalid request descriptor 不正なリクエストディスクリプタ .TP .B EBADRQC .\"O Invalid request code 不正なリクエストコード .TP .B EBADSLT .\"O Invalid slot 不正なスロット .\" EBFONT is defined but appears not to be used by kernel or glibc. .TP .B EBUSY .\"O Device or resource busy (POSIX.1) リソースが使用中である (POSIX.1) .TP .B ECANCELED .\"O Operation canceled (POSIX.1) 操作がキャンセルされた (POSIX.1) .TP .B ECHILD .\"O No child processes (POSIX.1) 子プロセスが無い (POSIX.1) .TP .B ECHRNG .\"O Channel number out of range チャンネル番号が範囲外である .TP .B ECOMM .\"O Communication error on send 送信時に通信エラーが発生した .TP .B ECONNABORTED .\"O Connection aborted (POSIX.1) 接続が中止された (POSIX.1) .TP .B ECONNREFUSED .\"O Connection refused (POSIX.1) 接続が拒否された (POSIX.1) .TP .B ECONNRESET .\"O Connection reset (POSIX.1) 接続がリセットされた (POSIX.1) .TP .B EDEADLK .\"O Resource deadlock avoided (POSIX.1) リソースのデッドロックを回避した (POSIX.1) .TP .B EDEADLOCK .\"O Synonym for .\"O .B EDEADLK .B EDEADLK の同義語 .TP .B EDESTADDRREQ .\"O Destination address required (POSIX.1) 宛先アドレスが必要である (POSIX.1) .TP .B EDOM .\"O Mathematics argument out of domain of function (POSIX.1, C99) 数学関数で引き数が領域外である (out of domain) .\" EDOTDOT is defined but appears to be unused .TP .B EDQUOT .\" POSIX just says "Reserved" .\"O Disk quota exceeded (POSIX.1) ディスク・クォータ (quota) を超過した (POSIX.1) .TP .B EEXIST .\"O File exists (POSIX.1) ファイルが存在する (POSIX.1) .TP .B EFAULT .\"O Bad address (POSIX.1) アドレスが不正である (POSIX.1) .TP .B EFBIG .\"O File too large (POSIX.1) ファイルが大き過ぎる (POSIX.1) .TP .B EHOSTDOWN .\"O Host is down ホストがダウンしている .TP .B EHOSTUNREACH .\"O Host is unreachable (POSIX.1) ホストに到達不能である (POSIX.1) .TP .B EIDRM .\"O Identifier removed (POSIX.1) 識別子が削除された (POSIX.1) .TP .B EILSEQ .\"O Illegal byte sequence (POSIX.1, C99) 不正なバイト列 (POSIX.1, C99) .TP .B EINPROGRESS .\"O Operation in progress (POSIX.1) 操作が実行中である (POSIX.1) .TP .B EINTR .\"O Interrupted function call (POSIX.1); see .\"O .BR signal (7). 関数呼び出しが割り込まれた (POSIX.1); .BR signal (7) 参照。 .TP .B EINVAL .\"O Invalid argument (POSIX.1) 引数が無効である (POSIX.1) .TP .B EIO .\"O Input/output error (POSIX.1) 入出力エラー (POSIX.1) .TP .B EISCONN .\"O Socket is connected (POSIX.1) ソケットが接続されている (POSIX.1) .TP .B EISDIR .\"O Is a directory (POSIX.1) ディレクトリである (POSIX.1) .TP .B EISNAM .\"O Is a named type file 名前付きのファイルである .TP .B EKEYEXPIRED .\"O Key has expired 鍵が期限切れとなった .TP .B EKEYREJECTED .\"O Key was rejected by service 鍵がサーバにより拒否された .TP .B EKEYREVOKED .\"O Key has been revoked 鍵が無効となった .TP .B EL2HLT .\"O Level 2 halted 停止 (レベル 2) .TP .B EL2NSYNC .\"O Level 2 not synchronized 同期できていない (レベル 2) .TP .B EL3HLT .\"O Level 3 halted 停止 (レベル 3) .TP .B EL3RST .\"O Level 3 halted リセット (レベル 3) .TP .B ELIBACC .\"O Cannot access a needed shared library 必要な共有ライブラリにアクセスできなかった .TP .B ELIBBAD .\"O Accessing a corrupted shared library 壊れた共有ライブラリにアクセスしようとした .TP .B ELIBMAX .\"O Attempting to link in too many shared libraries リンクしようとした共有ライブラリが多過ぎる .TP .B ELIBSCN .\"O lib section in a.out corrupted a.out のライブラリセクションが壊れている (corrupted) .TP .B ELIBEXEC .\"O Cannot exec a shared library directly 共有ライブラリを直接実行できなかった .TP .B ELOOP .\"O Too many levels of symbolic links (POSIX.1) シンボリック・リンクの回数が多過ぎる (POSIX.1) .\" ELNRNG is defined but appears to be unused .TP .B EMEDIUMTYPE .\"O Wrong medium type 間違ったメディア種別である .TP .B EMFILE .\"O Too many open files (POSIX.1) オープンされているファイルが多過ぎる (POSIX.1) .TP .B EMLINK .\"O Too many links (POSIX.1) リンクが多過ぎる (POSIX.1) .TP .B EMSGSIZE .\"O Message too long (POSIX.1) メッセージが長過ぎる (POSIX.1) .TP .B EMULTIHOP .\" POSIX says "Reserved" .\"O Multihop attempted (POSIX.1) マルチホップ (multihop) を試みた (POSIX.1) .TP .B ENAMETOOLONG .\"O Filename too long (POSIX.1) ファイル名が長過ぎる (POSIX.1) .\" ENAVAIL is defined, but appears not to be used .TP .B ENETDOWN .\"O Network is down (POSIX.1) ネットワークが不通である (POSIX.1) .TP .B ENETRESET .\"O Connection aborted by network (POSIX.1) 接続がネットワーク側から中止された (POSIX.1) .TP .B ENETUNREACH .\"O Network unreachable (POSIX.1) ネットワークが到達不能である (POSIX.1) .TP .B ENFILE .\"O Too many open files in system (POSIX.1) システム全体でオープンされているファイルが多過ぎる (POSIX.1) .\" ENOANO is defined but appears to be unused. .TP .B ENOBUFS .\"O No buffer space available (POSIX.1 (XSI STREAMS option)) 使用可能なバッファ空間がない (POSIX.1 (XSI STREAMS option)) .\" ENOCSI is defined but appears to be unused. .TP .B ENODATA .\"O No message is available on the STREAM head read queue (POSIX.1) ストリームの読み出しキューの先頭に読み出し可能なメッセージがない (POSIX.1) .TP .B ENODEV .\"O No such device (POSIX.1) そのようなデバイスは無い (POSIX.1) .TP .B ENOENT .\"O No such file or directory (POSIX.1) そのようなファイルやディレクトリは無い (POSIX.1) .TP .B ENOEXEC .\"O Exec format error (POSIX.1) 実行ファイル形式のエラー (POSIX.1) .TP .B ENOKEY .\"O Required key not available 要求された鍵が利用できない .TP .B ENOLCK .\"O No locks available (POSIX.1) 利用できるロックが無い (POSIX.1) .TP .B ENOLINK .\" POSIX says "Reserved" .\"O Link has been severed (POSIX.1) リンクが切れている (POSIX.1) .TP .B ENOMEDIUM .\"O No medium found メディアが見つからない .TP .B ENOMEM .\"O Not enough space (POSIX.1) 十分な空きメモリ領域が無い (POSIX.1) .TP .B ENOMSG .\"O No message of the desired type (POSIX.1) 要求された型のメッセージが存在しない (POSIX.1) .TP .B ENONET .\"O Machine is not on the network マシンがネットワーク上にない .TP .B ENOPKG .\"O Package not installed パッケージがインストールされていない .TP .B ENOPROTOOPT .\"O Protocol not available (POSIX.1) 指定されたプロトコルが利用できない (POSIX.1) .TP .B ENOSPC .\"O No space left on device (POSIX.1) デバイスに空き領域が無い (POSIX.1) .TP .B ENOSR .\"O No STREAM resources (POSIX.1 (XSI STREAMS option)) 指定されたストリーム・リソースが存在しない (POSIX.1 (XSI STREAMS option)) .TP .B ENOSTR .\"O Not a STREAM (POSIX.1 (XSI STREAMS option)) ストリームではない (POSIX.1 (XSI STREAMS option)) .TP .B ENOSYS .\"O Function not implemented (POSIX.1) 関数が実装されていない (POSIX.1) .TP .B ENOTBLK .\"O Block device required ブロックデバイスが必要である .TP .B ENOTCONN .\"O The socket is not connected (POSIX.1) ソケットが接続されていない (POSIX.1) .TP .B ENOTDIR .\"O Not a directory (POSIX.1) ディレクトリではない (POSIX.1) .TP .B ENOTEMPTY .\"O Directory not empty (POSIX.1) ディレクトリが空ではない (POSIX.1) .\" ENOTNAM is defined but appears to be unused. .TP .B ENOTSOCK .\"O Not a socket (POSIX.1) ソケットではない (POSIX.1) .TP .B ENOTSUP .\"O Operation not supported (POSIX.1) 操作がサポートされていない (POSIX.1) .TP .B ENOTTY .\"O Inappropriate I/O control operation (POSIX.1) I/O 制御操作が適切でない (POSIX.1) .TP .B ENOTUNIQ .\"O Name not unique on network 名前がネットワークで一意ではない .TP .B ENXIO .\"O No such device or address (POSIX.1) そのようなデバイスやアドレスはない (POSIX.1) .TP .B EOPNOTSUPP .\"O Operation not supported on socket (POSIX.1) ソケットでサポートしていない操作である (POSIX.1) .sp .\"O .RB ( ENOTSUP .\"O and .\"O .B EOPNOTSUPP .\"O have the same value on Linux, but .\"O according to POSIX.1 these error values should be distinct.) (Linux では .B ENOTSUP と .B EOPNOTSUPP は同じ値を持つが、 POSIX.1 に従えば両者のエラー値は区別されるべきである。) .TP .B EOVERFLOW .\"O Value too large to be stored in data type (POSIX.1) 指定されたデータ型に格納するには値が大き過ぎる (POSIX.1) .TP .B EPERM .\"O Operation not permitted (POSIX.1) 操作が許可されていない (POSIX.1) .TP .B EPFNOSUPPORT .\"O Protocol family not supported サポートされていないプロトコルファミリーである .TP .B EPIPE .\"O Broken pipe (POSIX.1) パイプが壊れている (POSIX.1) .TP .B EPROTO .\"O Protocol error (POSIX.1) プロトコル・エラー (POSIX.1) .TP .B EPROTONOSUPPORT .\"O Protocol not supported (POSIX.1) プロトコルがサポートされていない (POSIX.1) .TP .B EPROTOTYPE .\"O Protocol wrong type for socket (POSIX.1) ソケットに指定できないプロトコル・タイプである (POSIX.1) .TP .B ERANGE .\"O Result too large (POSIX.1, C99) 結果が大き過ぎる (POSIX.1, C99) .TP .B EREMCHG .\"O Remote address changed リモートアドレスが変わった .TP .B EREMOTE .\"O Object is remote オブジェクトがリモートにある .TP .B EREMOTEIO .\"O Remote I/O error リモート I/O エラー .TP .B ERESTART .\"O Interrupted system call should be restarted システムコールが中断され再スタートが必要である .TP .B EROFS .\"O Read-only file system (POSIX.1) 読み出し専用のファイルシステムである (POSIX.1) .TP .B ESHUTDOWN .\"O Cannot send after transport endpoint shutdown 通信相手がシャットダウンされて送信できない .TP .B ESPIPE .\"O Invalid seek (POSIX.1) 無効なシーク (POSIX.1) .TP .B ESOCKTNOSUPPORT .\"O Socket type not supported サポートされていないソケット種別である .TP .B ESRCH .\"O No such process (POSIX.1) そのようなプロセスは無い (POSIX.1) .\" ESRMNT is defined but appears not to be used .TP .B ESTALE .\"O Stale file handle (POSIX.1) ファイルハンドルが古い状態になっている (POSIX.1) .sp .\"O This error can occur for NFS and for other file systems NFS や他のファイルシステムで起こりうる。 .TP .B ESTRPIPE .\"O Streams pipe error ストリーム・パイプ・エラー .TP .B ETIME .\"O Timer expired .\"O (POSIX.1 (XSI STREAMS option)) 時間が経過した (POSIX.1 (XSI STREAMS option)) .sp .\"O (POSIX.1 says "STREAM .\"O .BR ioctl (2) .\"O timeout") (POSIX.1 では "STREAM .BR ioctl (2) timeout" と書かれている) .TP .B ETIMEDOUT .\"O Connection timed out (POSIX.1) 操作がタイムアウトした (POSIX.1) .\" ETOOMANYREFS is defined, but appears not to be used. .TP .B ETXTBSY .\"O Text file busy (POSIX.1) テキストファイルが使用中である (POSIX.1) .TP .B EUCLEAN .\"Omotoki: 意味が分からないので、そのまま原文を残してある。 .\"O Structure needs cleaning Structure needs cleaning .TP .B EUNATCH .\"O Protocol driver not attached プロトコルのドライバが付与 (attach) されていない .TP .B EUSERS .\"O Too many users ユーザ数が多過ぎる .TP .B EWOULDBLOCK .\"O Operation would block (may be same value as .\"O .BR EAGAIN ) .\"O (POSIX.1) 操作がブロックされる見込みである .RB ( EAGAIN と同じ値でもよい) (POSIX.1) .TP .B EXDEV .\"O Improper link (POSIX.1) 不適切なリンク (POSIX.1) .TP .B EXFULL .\"O Exchange full 変換テーブルが一杯である .\"O .SH NOTES .SH 注意 .\"O A common mistake is to do 以下はよくやる間違いである。 .in +4n .nf if (somecall() == \-1) { printf("somecall() failed\en"); if (errno == ...) { ... } } .fi .in .\"O where .\"O .I errno .\"O no longer needs to have the value it had upon return from .\"O .IR somecall () .\"O (i.e., it may have been changed by the .\"O .BR printf (3)). このようにすると、参照している時点では .I errno はもはや .IR somecall () から返された値を保持しているとは限らない .RB ( printf (3) により変更されているかもしれない)。 .\"O If the value of .\"O .I errno .\"O should be preserved across a library call, it must be saved: ライブラリコールをまたいで .I errno の値を保存したい場合は、以下のように保存しなければならない: .in +4n .nf if (somecall() == \-1) { int errsv = errno; printf("somecall() failed\en"); if (errsv == ...) { ... } } .fi .in .PP .\"O It was common in traditional C to declare .\"O .I errno .\"O manually .\"O (i.e., .\"O .IR "extern int errno" ) .\"O instead of including .\"O .IR . .\"O .BR "Do not do this" . .\"O It will not work with modern versions of the C library. .\"O However, on (very) old UNIX systems, there may be no .\"O .I .\"O and the declaration is needed. 昔の C では、 .I をインクルードするのではなく .I errno を手動で .RI ( "extern int errno" のように) 定義するのが一般的であった。 .BR "このようなことはしないこと" "。" こうすると、最近のバージョンの C ライブラリでは正しく動作しないだろう。 しかし、(非常に) 古い UNIX システムでは、 .I がなく、宣言が必要なことがあるかもしれない。 .\"O .SH "SEE ALSO" .BR err (3), .BR error (3), .BR perror (3), .BR strerror (3)