1 .\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl)
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 .\" GNU General Public License for more details.
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
24 .\" 5 Oct 2002, Modified by Michael Kerrisk <mtk.manpages@gmail.com>
25 .\" Updated for POSIX.1 2001
26 .\" 2004-12-17 Martin Schulze <joey@infodrom.org>, mtk
27 .\" Removed errno declaration prototype, added notes
28 .\" 2006-02-09 Kurt Wall, mtk
29 .\" Added non-POSIX errors
31 .TH ERRNO 3 2008-07-09 "" "Linux Programmer's Manual"
33 errno \- number of last error
37 .\".BI "extern int " errno ;
41 header file defines the integer variable
43 which is set by system calls and some library functions in the event
44 of an error to indicate what went wrong.
45 Its value is significant only when the return value of
46 the call indicated an error
47 (i.e., \-1 from most system calls;
48 \-1 or NULL from most library functions);
49 a function that succeeds
54 Valid error numbers are all nonzero; \fIerrno\fP is never set to zero
55 by any system call or library function.
57 For some system calls and library functions (e.g.,
59 \-1 is a valid return on success.
60 In such cases, a successful return can be distinguished from an error
63 to zero before the call, and then,
64 if the call returns a status that indicates that an error
65 may have occurred, checking to see if
69 \fIerrno\fP is defined by the ISO C standard to be a modifiable lvalue
70 of type \fIint\fP, and must not be explicitly declared; \fIerrno\fP
72 \fIerrno\fP is thread-local; setting it in one thread
73 does not affect its value in any other thread.
75 All the error names specified by POSIX.1
76 must have distinct values, with the exception of
80 which may be the same.
82 .\" The following is now
83 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
84 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
85 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
86 .\" coding errors in multibyte or wide characters.
88 Below is a list of the symbolic error names that are defined on Linux.
89 Some of these are marked
91 indicating that the name is defined by POSIX.1-2001, or
93 indicating that the name is defined by C99.
96 Argument list too long (POSIX.1)
99 Permission denied (POSIX.1)
102 Address already in use (POSIX.1)
105 Address not available (POSIX.1)
106 .\" EADV is only an error on HURD(?)
109 Address family not supported (POSIX.1)
112 Resource temporarily unavailable (may be the same value as
117 Connection already in progress (POSIX.1)
123 Bad file descriptor (POSIX.1)
126 File descriptor in bad state
129 Bad message (POSIX.1)
132 Invalid request descriptor
139 .\" EBFONT is defined but appears not to be used by kernel or glibc.
142 Device or resource busy (POSIX.1)
145 Operation canceled (POSIX.1)
148 No child processes (POSIX.1)
151 Channel number out of range
154 Communication error on send
157 Connection aborted (POSIX.1)
160 Connection refused (POSIX.1)
163 Connection reset (POSIX.1)
166 Resource deadlock avoided (POSIX.1)
173 Destination address required (POSIX.1)
176 Mathematics argument out of domain of function (POSIX.1, C99)
177 .\" EDOTDOT is defined but appears to be unused
180 .\" POSIX just says "Reserved"
181 Disk quota exceeded (POSIX.1)
184 File exists (POSIX.1)
187 Bad address (POSIX.1)
190 File too large (POSIX.1)
196 Host is unreachable (POSIX.1)
199 Identifier removed (POSIX.1)
202 Illegal byte sequence (POSIX.1, C99)
205 Operation in progress (POSIX.1)
208 Interrupted function call (POSIX.1); see
212 Invalid argument (POSIX.1)
215 Input/output error (POSIX.1)
218 Socket is connected (POSIX.1)
221 Is a directory (POSIX.1)
230 Key was rejected by service
239 Level 2 not synchronized
248 Cannot access a needed shared library
251 Accessing a corrupted shared library
254 Attempting to link in too many shared libraries
257 lib section in a.out corrupted
260 Cannot exec a shared library directly
263 Too many levels of symbolic links (POSIX.1)
264 .\" ELNRNG is defined but appears to be unused
270 Too many open files (POSIX.1)
273 Too many links (POSIX.1)
276 Message too long (POSIX.1)
279 .\" POSIX says "Reserved"
280 Multihop attempted (POSIX.1)
283 Filename too long (POSIX.1)
284 .\" ENAVAIL is defined, but appears not to be used
287 Network is down (POSIX.1)
290 Connection aborted by network (POSIX.1)
293 Network unreachable (POSIX.1)
296 Too many open files in system (POSIX.1)
297 .\" ENOANO is defined but appears to be unused.
300 No buffer space available (POSIX.1 (XSI STREAMS option))
301 .\" ENOCSI is defined but appears to be unused.
304 No message is available on the STREAM head read queue (POSIX.1)
307 No such device (POSIX.1)
310 No such file or directory (POSIX.1)
313 Exec format error (POSIX.1)
316 Required key not available
319 No locks available (POSIX.1)
322 .\" POSIX says "Reserved"
323 Link has been severed (POSIX.1)
329 Not enough space (POSIX.1)
332 No message of the desired type (POSIX.1)
335 Machine is not on the network
338 Package not installed
341 Protocol not available (POSIX.1)
344 No space left on device (POSIX.1)
347 No STREAM resources (POSIX.1 (XSI STREAMS option))
350 Not a STREAM (POSIX.1 (XSI STREAMS option))
353 Function not implemented (POSIX.1)
356 Block device required
359 The socket is not connected (POSIX.1)
362 Not a directory (POSIX.1)
365 Directory not empty (POSIX.1)
366 .\" ENOTNAM is defined but appears to be unused.
369 Not a socket (POSIX.1)
372 Operation not supported (POSIX.1)
375 Inappropriate I/O control operation (POSIX.1)
378 Name not unique on network
381 No such device or address (POSIX.1)
384 Operation not supported on socket (POSIX.1)
389 have the same value on Linux, but
390 according to POSIX.1 these error values should be distinct.)
393 Value too large to be stored in data type (POSIX.1)
396 Operation not permitted (POSIX.1)
399 Protocol family not supported
402 Broken pipe (POSIX.1)
405 Protocol error (POSIX.1)
408 Protocol not supported (POSIX.1)
411 Protocol wrong type for socket (POSIX.1)
414 Result too large (POSIX.1, C99)
417 Remote address changed
426 Interrupted system call should be restarted
429 Read-only file system (POSIX.1)
432 Cannot send after transport endpoint shutdown
435 Invalid seek (POSIX.1)
438 Socket type not supported
441 No such process (POSIX.1)
442 .\" ESRMNT is defined but appears not to be used
445 Stale file handle (POSIX.1)
447 This error can occur for NFS and for other file systems
454 (POSIX.1 (XSI STREAMS option))
456 (POSIX.1 says "STREAM
461 Connection timed out (POSIX.1)
462 .\" ETOOMANYREFS is defined, but appears not to be used.
465 Text file busy (POSIX.1)
468 Structure needs cleaning
471 Protocol driver not attached
477 Operation would block (may be same value as
482 Improper link (POSIX.1)
487 A common mistake is to do
491 if (somecall() == \-1) {
492 printf("somecall() failed\en");
493 if (errno == ...) { ... }
500 no longer needs to have the value it had upon return from
502 (i.e., it may have been changed by the
506 should be preserved across a library call, it must be saved:
510 if (somecall() == \-1) {
512 printf("somecall() failed\en");
513 if (errsv == ...) { ... }
518 It was common in traditional C to declare
522 .IR "extern int errno" )
525 .BR "Do not do this" .
526 It will not work with modern versions of the C library.
527 However, on (very) old UNIX systems, there may be no
529 and the declaration is needed.