| .\" 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 <mtk-manpages@gmx.net> |
| .\" Updated for POSIX 1003.1 2001 |
| .\" 2004-12-17 Martin Schulze <joey@infodrom.org>, mtk |
| .\" Removed errno declaration prototype, added notes |
| .\" 2006-02-09 Kurt Wall, mtk |
| .\" Added non-POSIX errors |
| .\" |
| .TH ERRNO 3 2006-02-09 "" "Library functions" |
| .SH NAME |
| errno \- number of last error |
| .SH SYNOPSIS |
| .B #include <errno.h> |
| .\".sp |
| .\".BI "extern int " errno ; |
| .SH DESCRIPTION |
| The |
| .I <errno.h> |
| header file defines the integer variable |
| .BR errno , |
| which is set by system calls and some library functions in the event |
| of an error to indicate what went wrong. |
| Its value is significant only when the call |
| returned an error (usually \-1), and a function that does succeed |
| is allowed to change |
| .BR errno . |
| |
| Sometimes, when \-1 is also a valid successful return value |
| one has to zero |
| .B errno |
| before the call in order to detect possible errors. |
| |
| \fBerrno\fR is defined by the ISO C standard to be a modifiable lvalue |
| of type \fBint\fR, and must not be explicitly declared; \fBerrno\fR |
| may be a macro. \fBerrno\fR is thread-local; setting it in one thread |
| does not affect its value in any other thread. |
| |
| Valid error numbers are all non-zero; \fBerrno\fR is never set to zero |
| by any library function. All the error names specified by POSIX.1 |
| must have distinct values, with the exception of |
| .B EAGAIN |
| and |
| .BR EWOULDBLOCK , |
| which may be the same. |
| |
| .\" The following is now |
| .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of |
| .\" these, \fBEDOM\fR and \fBERANGE\fR are in the ISO C standard. ISO C |
| .\" Amendment 1 defines the additional error number \fBEILSEQ\fR for |
| .\" coding errors in multibyte or wide characters. |
| .\" |
| Below is a list of the symbolic error names that are defined on Linux. |
| Some of these are marked |
| .IR POSIX.1 , |
| indicating that the name is defined by POSIX.1-2001, or |
| .IR C99 , |
| indicating that the name is defined by C99. |
| .TP |
| .BR E2BIG |
| Argument list too long (POSIX.1) |
| .TP |
| .BR EACCES |
| Permission denied (POSIX.1) |
| .TP |
| .BR EADDRINUSE |
| Address already in use (POSIX.1) |
| .TP |
| .BR EADDRNOTAVAIL |
| Address not available (POSIX.1) |
| .\" EADV is only an error on HURD(?) |
| .TP |
| .BR EAFNOSUPPORT |
| Address family not supported (POSIX.1) |
| .TP |
| .BR EAGAIN |
| Resource temporarily unavailable (may be the same value as |
| .BR EWOULDBLOCK ) |
| (POSIX.1) |
| .TP |
| .BR EALREADY |
| Connection already in progress (POSIX.1) |
| .TP |
| .BR EBADE |
| Invalid exchange |
| .TP |
| .BR EBADF |
| Bad file descriptor (POSIX.1) |
| .TP |
| .BR EBADFD |
| File descriptor in bad state |
| .TP |
| .BR EBADMSG |
| Bad message (POSIX.1) |
| .TP |
| .BR EBADR |
| Invalid request descriptor |
| .TP |
| .BR EBADRQC |
| Invalid request code |
| .TP |
| .BR EBADSLT |
| Invalid slot |
| .\" EBFONT is defined but appears not to be used by kernel or glibc. |
| .TP |
| .BR EBUSY |
| Device or resource busy (POSIX.1) |
| .TP |
| .BR ECANCELED |
| Operation canceled (POSIX.1) |
| .TP |
| .BR ECHILD |
| No child processes (POSIX.1) |
| .TP |
| .B ECHRNG |
| Channel number out of range |
| .TP |
| .B ECOMM |
| Communication error on send |
| .TP |
| .BR ECONNABORTED |
| Connection aborted (POSIX.1) |
| .TP |
| .BR ECONNREFUSED |
| Connection refused (POSIX.1) |
| .TP |
| .BR ECONNRESET |
| Connection reset (POSIX.1) |
| .TP |
| .BR EDEADLK |
| Resource deadlock avoided (POSIX.1) |
| .TP |
| .BR EDEADLOCK |
| Synonym for |
| .B EDEADLK |
| .TP |
| .BR EDESTADDRREQ |
| Destination address required (POSIX.1) |
| .TP |
| .BR EDOM |
| Mathematics argument out of domain of function (POSIX.1, C99) |
| .\" EDOTDOT is defined but appears to be unused |
| .TP |
| .BR EDQUOT |
| .\" POSIX just says "Reserved" |
| Disk quota exceeded (POSIX.1) |
| .TP |
| .BR EEXIST |
| File exists (POSIX.1) |
| .TP |
| .BR EFAULT |
| Bad address (POSIX.1) |
| .TP |
| .BR EFBIG |
| File too large (POSIX.1) |
| .TP |
| .BR EHOSTDOWN |
| Host is down |
| .TP |
| .BR EHOSTUNREACH |
| Host is unreachable (POSIX.1) |
| .TP |
| .BR EIDRM |
| Identifier removed (POSIX.1) |
| .TP |
| .BR EILSEQ |
| Illegal byte sequence (POSIX.1, C99) |
| .TP |
| .BR EINPROGRESS |
| Operation in progress (POSIX.1) |
| .TP |
| .BR EINTR |
| Interrupted function call (POSIX.1) |
| .TP |
| .BR EINVAL |
| Invalid argument (POSIX.1) |
| .TP |
| .BR EIO |
| Input/output error (POSIX.1) |
| .TP |
| .BR EISCONN |
| Socket is connected (POSIX.1) |
| .TP |
| .BR EISDIR |
| Is a directory (POSIX.1) |
| .TP |
| .BR EISNAM |
| Is a named type file |
| .TP |
| .BR EKEYEXPIRED |
| Key has expired |
| .TP |
| .BR EKEYREJECTED |
| Key was rejected by service |
| .TP |
| .BR EKEYREVOKED |
| Key has been revoked |
| .TP |
| .B EL2HLT |
| Level 2 halted |
| .TP |
| .B EL2NSYNC |
| Level 2 not synchronized |
| .TP |
| .B EL3HLT |
| Level 3 halted |
| .TP |
| .B EL3RST |
| Level 3 halted |
| .TP |
| .BR ELIBACC |
| Cannot access a needed shared library |
| .TP |
| .BR ELIBBAD |
| Accessing a corrupted shared library |
| .TP |
| .BR ELIBMAX |
| Attempting to link in too many shared libraries |
| .TP |
| .BR ELIBSCN |
| lib section in a.out corrupted |
| .TP |
| .BR ELIBEXEC |
| Cannot exec a shared library directly |
| .TP |
| .BR ELOOP |
| Too many levels of symbolic links (POSIX.1) |
| .\" ELNRNG is defined but appears to be unused |
| .TP |
| .BR EMEDIUMTYPE |
| Wrong medium type |
| .TP |
| .BR EMFILE |
| Too many open files (POSIX.1) |
| .TP |
| .BR EMLINK |
| Too many links (POSIX.1) |
| .TP |
| .BR EMSGSIZE |
| Message too long (POSIX.1) |
| .TP |
| .BR EMULTIHOP |
| .\" POSIX says "Reserved" |
| Multihop attempted (POSIX.1) |
| .TP |
| .BR ENAMETOOLONG |
| Filename too long (POSIX.1) |
| .\" ENAVAIL is defined, but appears not to be used |
| .TP |
| .BR ENETDOWN |
| Network is down (POSIX.1) |
| .TP |
| .BR ENETRESET |
| Connection aborted by network (POSIX.1) |
| .TP |
| .BR ENETUNREACH |
| Network unreachable (POSIX.1) |
| .TP |
| .BR ENFILE |
| Too many open files in system (POSIX.1) |
| .\" ENOANO is defined but appears to be unused. |
| .TP |
| .BR ENOBUFS |
| No buffer space available (POSIX.1 (XSI STREAMS option)) |
| .\" ENOCSI is defined but appears to be unused. |
| .TP |
| .BR ENODATA |
| No message is available on the STREAM head read queue (POSIX.1) |
| .TP |
| .BR ENODEV |
| No such device (POSIX.1) |
| .TP |
| .BR ENOENT |
| No such file or directory (POSIX.1) |
| .TP |
| .BR ENOEXEC |
| Exec format error (POSIX.1) |
| .TP |
| .BR ENOKEY |
| Reuired key not available |
| .TP |
| .BR ENOLCK |
| No locks available (POSIX.1) |
| .TP |
| .BR ENOLINK |
| .\" POSIX says "Reserved" |
| Link has been severed (POSIX.1) |
| .TP |
| .BR ENOMEDIUM |
| No medium found |
| .TP |
| .BR ENOMEM |
| Not enough space (POSIX.1) |
| .TP |
| .BR ENOMSG |
| No message of the desired type (POSIX.1) |
| .TP |
| .BR ENONET |
| Machine is not on the network |
| .TP |
| .BR ENOPKG |
| Package not installed |
| .TP |
| .BR ENOPROTOOPT |
| Protocol not available (POSIX.1) |
| .TP |
| .BR ENOSPC |
| No space left on device (POSIX.1) |
| .TP |
| .BR ENOSR |
| No STREAM resources (POSIX.1 (XSI STREAMS option)) |
| .TP |
| .BR ENOSTR |
| Not a STREAM (POSIX.1 (XSI STREAMS option)) |
| .TP |
| .BR ENOSYS |
| Function not implemented (POSIX.1) |
| .TP |
| .BR ENOTBLK |
| Block device required |
| .TP |
| .BR ENOTCONN |
| The socket is not connected (POSIX.1) |
| .TP |
| .BR ENOTDIR |
| Not a directory (POSIX.1) |
| .TP |
| .BR ENOTEMPTY |
| Directory not empty (POSIX.1) |
| .\" ENOTNAM is defined but appears to be unused. |
| .TP |
| .BR ENOTSOCK |
| Not a socket (POSIX.1) |
| .TP |
| .BR ENOTSUP |
| Operation not supported (POSIX.1) |
| .TP |
| .BR ENOTTY |
| Inappropriate I/O control operation (POSIX.1) |
| .TP |
| .BR ENOTUNIQ |
| Name not unique on network |
| .TP |
| .BR ENXIO |
| No such device or address (POSIX.1) |
| .TP |
| .BR EOPNOTSUPP |
| Operation not supported on socket (POSIX.1) |
| .sp |
| (ENOTSUP and EOPNOTSUPP have the same value on Linux, but |
| according to POSIX.1 these error values should be distinct.) |
| .TP |
| .BR EOVERFLOW |
| Value too large to be stored in data type (POSIX.1) |
| .TP |
| .BR EPERM |
| Operation not permitted (POSIX.1) |
| .TP |
| .BR EPFNOSUPPORT |
| Protocol family not supported |
| .TP |
| .BR EPIPE |
| Broken pipe (POSIX.1) |
| .TP |
| .BR EPROTO |
| Protocol error (POSIX.1) |
| .TP |
| .BR EPROTONOSUPPORT |
| Protocol not supported (POSIX.1) |
| .TP |
| .BR EPROTOTYPE |
| Protocol wrong type for socket (POSIX.1) |
| .TP |
| .BR ERANGE |
| Result too large (POSIX.1, C99) |
| .TP |
| .BR EREMCHG |
| Remote address changed |
| .TP |
| .BR EREMOTE |
| Object is remote |
| .TP |
| .BR EREMOTEIO |
| Remote I/O error |
| .TP |
| .BR ERESTART |
| Interrupted system call should be restarted |
| .TP |
| .BR EROFS |
| Read-only file system (POSIX.1) |
| .TP |
| .BR ESHUTDOWN |
| Cannot send after transport endpoint shutdown |
| .TP |
| .BR ESPIPE |
| Invalid seek (POSIX.1) |
| .TP |
| .BR ESOCKTNOSUPPORT |
| Socket type not supported |
| .TP |
| .BR ESRCH |
| No such process (POSIX.1) |
| .\" ESRMNT is defined but appears not to be used |
| .TP |
| .BR ESTALE |
| Stale file handle (POSIX.1)) |
| .sp |
| This error can occur for NFS and for other file systems |
| .TP |
| .BR ESTRPIPE |
| Streams pipe error |
| .TP |
| .BR ETIME |
| Timer expired |
| (POSIX.1 (XSI STREAMS option)) |
| .sp |
| (POSIX.1 says "STREAM |
| .BR ioctl () |
| timeout") |
| .TP |
| .BR ETIMEDOUT |
| Connection timed out (POSIX.1) |
| .\" ETOOMANYREFS is defined, but appears not to be used. |
| .TP |
| .BR ETXTBSY |
| Text file busy (POSIX.1) |
| .TP |
| .BR EUCLEAN |
| Struture needs cleaning |
| .TP |
| .BR EUNATCH |
| Protocol driver not attached |
| .TP |
| .BR EUSERS |
| Too many users |
| .TP |
| .BR EWOULDBLOCK |
| Operation would block (may be same value as |
| .BR EAGAIN ) |
| (POSIX.1) |
| .TP |
| .BR EXDEV |
| Improper link (POSIX.1) |
| .TP |
| .B EXFULL |
| Exchange full |
| .SH NOTES |
| A common mistake is to do |
| .RS |
| .nf |
| |
| if (somecall() == \-1) { |
| printf("somecall() failed\en"); |
| if (errno == ...) { ... } |
| } |
| |
| .fi |
| .RE |
| where |
| .I errno |
| no longer needs to have the value it had upon return from |
| .IR somecall () |
| (i.e., it may have been changed by the |
| .BR printf ()). |
| If the value of |
| .I errno |
| should be preserved across a library call, it must be saved: |
| .RS |
| .nf |
| |
| if (somecall() == \-1) { |
| int errsv = errno; |
| printf("somecall() failed\en"); |
| if (errsv == ...) { ... } |
| } |
| .fi |
| .RE |
| .PP |
| It was common in traditional C to declare |
| .I errno |
| manually |
| (i.e., |
| .IR "extern int errno" ) |
| instead of including |
| .IR <errno.h> . |
| .BR "Do not do this" . |
| It will not work with modern versions of the C library. |
| However, on (very) old Unix systems, there may be no |
| .I <errno.h> |
| and the declaration is needed. |
| .SH "SEE ALSO" |
| .BR err (3), |
| .BR perror (3), |
| .BR strerror (3) |