1 .\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl)
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 .\" GNU General Public License for more details.
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
23 .\" 5 Oct 2002, Modified by Michael Kerrisk <mtk.manpages@gmail.com>
24 .\" Updated for POSIX.1 2001
25 .\" 2004-12-17 Martin Schulze <joey@infodrom.org>, mtk
26 .\" Removed errno declaration prototype, added notes
27 .\" 2006-02-09 Kurt Wall, mtk
28 .\" Added non-POSIX errors
30 .TH ERRNO 3 2008-07-09 "" "Linux Programmer's Manual"
32 errno \- number of last error
36 .\".BI "extern int " errno ;
40 header file defines the integer variable
42 which is set by system calls and some library functions in the event
43 of an error to indicate what went wrong.
44 Its value is significant only when the return value of
45 the call indicated an error
46 (i.e., \-1 from most system calls;
47 \-1 or NULL from most library functions);
48 a function that succeeds
53 Valid error numbers are all nonzero; \fIerrno\fP is never set to zero
54 by any system call or library function.
56 For some system calls and library functions (e.g.,
58 \-1 is a valid return on success.
59 In such cases, a successful return can be distinguished from an error
62 to zero before the call, and then,
63 if the call returns a status that indicates that an error
64 may have occurred, checking to see if
68 \fIerrno\fP is defined by the ISO C standard to be a modifiable lvalue
69 of type \fIint\fP, and must not be explicitly declared; \fIerrno\fP
71 \fIerrno\fP is thread-local; setting it in one thread
72 does not affect its value in any other thread.
74 All the error names specified by POSIX.1
75 must have distinct values, with the exception of
79 which may be the same.
81 .\" The following is now
82 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
83 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
84 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
85 .\" coding errors in multibyte or wide characters.
87 Below is a list of the symbolic error names that are defined on Linux.
88 Some of these are marked
90 indicating that the name is defined by POSIX.1-2001, or
92 indicating that the name is defined by C99.
95 Argument list too long (POSIX.1)
98 Permission denied (POSIX.1)
101 Address already in use (POSIX.1)
104 Address not available (POSIX.1)
105 .\" EADV is only an error on HURD(?)
108 Address family not supported (POSIX.1)
111 Resource temporarily unavailable (may be the same value as
116 Connection already in progress (POSIX.1)
122 Bad file descriptor (POSIX.1)
125 File descriptor in bad state
128 Bad message (POSIX.1)
131 Invalid request descriptor
138 .\" EBFONT is defined but appears not to be used by kernel or glibc.
141 Device or resource busy (POSIX.1)
144 Operation canceled (POSIX.1)
147 No child processes (POSIX.1)
150 Channel number out of range
153 Communication error on send
156 Connection aborted (POSIX.1)
159 Connection refused (POSIX.1)
162 Connection reset (POSIX.1)
165 Resource deadlock avoided (POSIX.1)
172 Destination address required (POSIX.1)
175 Mathematics argument out of domain of function (POSIX.1, C99)
176 .\" EDOTDOT is defined but appears to be unused
179 .\" POSIX just says "Reserved"
180 Disk quota exceeded (POSIX.1)
183 File exists (POSIX.1)
186 Bad address (POSIX.1)
189 File too large (POSIX.1)
195 Host is unreachable (POSIX.1)
198 Identifier removed (POSIX.1)
201 Illegal byte sequence (POSIX.1, C99)
204 Operation in progress (POSIX.1)
207 Interrupted function call (POSIX.1); see
211 Invalid argument (POSIX.1)
214 Input/output error (POSIX.1)
217 Socket is connected (POSIX.1)
220 Is a directory (POSIX.1)
229 Key was rejected by service
238 Level 2 not synchronized
247 Cannot access a needed shared library
250 Accessing a corrupted shared library
253 Attempting to link in too many shared libraries
256 lib section in a.out corrupted
259 Cannot exec a shared library directly
262 Too many levels of symbolic links (POSIX.1)
263 .\" ELNRNG is defined but appears to be unused
269 Too many open files (POSIX.1)
272 Too many links (POSIX.1)
275 Message too long (POSIX.1)
278 .\" POSIX says "Reserved"
279 Multihop attempted (POSIX.1)
282 Filename too long (POSIX.1)
283 .\" ENAVAIL is defined, but appears not to be used
286 Network is down (POSIX.1)
289 Connection aborted by network (POSIX.1)
292 Network unreachable (POSIX.1)
295 Too many open files in system (POSIX.1)
296 .\" ENOANO is defined but appears to be unused.
299 No buffer space available (POSIX.1 (XSI STREAMS option))
300 .\" ENOCSI is defined but appears to be unused.
303 No message is available on the STREAM head read queue (POSIX.1)
306 No such device (POSIX.1)
309 No such file or directory (POSIX.1)
312 Exec format error (POSIX.1)
315 Required key not available
318 No locks available (POSIX.1)
321 .\" POSIX says "Reserved"
322 Link has been severed (POSIX.1)
328 Not enough space (POSIX.1)
331 No message of the desired type (POSIX.1)
334 Machine is not on the network
337 Package not installed
340 Protocol not available (POSIX.1)
343 No space left on device (POSIX.1)
346 No STREAM resources (POSIX.1 (XSI STREAMS option))
349 Not a STREAM (POSIX.1 (XSI STREAMS option))
352 Function not implemented (POSIX.1)
355 Block device required
358 The socket is not connected (POSIX.1)
361 Not a directory (POSIX.1)
364 Directory not empty (POSIX.1)
365 .\" ENOTNAM is defined but appears to be unused.
368 Not a socket (POSIX.1)
371 Operation not supported (POSIX.1)
374 Inappropriate I/O control operation (POSIX.1)
377 Name not unique on network
380 No such device or address (POSIX.1)
383 Operation not supported on socket (POSIX.1)
388 have the same value on Linux, but
389 according to POSIX.1 these error values should be distinct.)
392 Value too large to be stored in data type (POSIX.1)
395 Operation not permitted (POSIX.1)
398 Protocol family not supported
401 Broken pipe (POSIX.1)
404 Protocol error (POSIX.1)
407 Protocol not supported (POSIX.1)
410 Protocol wrong type for socket (POSIX.1)
413 Result too large (POSIX.1, C99)
416 Remote address changed
425 Interrupted system call should be restarted
428 Read-only file system (POSIX.1)
431 Cannot send after transport endpoint shutdown
434 Invalid seek (POSIX.1)
437 Socket type not supported
440 No such process (POSIX.1)
441 .\" ESRMNT is defined but appears not to be used
444 Stale file handle (POSIX.1)
446 This error can occur for NFS and for other file systems
453 (POSIX.1 (XSI STREAMS option))
455 (POSIX.1 says "STREAM
460 Connection timed out (POSIX.1)
461 .\" ETOOMANYREFS is defined, but appears not to be used.
464 Text file busy (POSIX.1)
467 Structure needs cleaning
470 Protocol driver not attached
476 Operation would block (may be same value as
481 Improper link (POSIX.1)
486 A common mistake is to do
490 if (somecall() == \-1) {
491 printf("somecall() failed\en");
492 if (errno == ...) { ... }
499 no longer needs to have the value it had upon return from
501 (i.e., it may have been changed by the
505 should be preserved across a library call, it must be saved:
509 if (somecall() == \-1) {
511 printf("somecall() failed\en");
512 if (errsv == ...) { ... }
517 It was common in traditional C to declare
521 .IR "extern int errno" )
524 .BR "Do not do this" .
525 It will not work with modern versions of the C library.
526 However, on (very) old Unix systems, there may be no
528 and the declaration is needed.