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 2006-02-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 call
45 returned an error (usually \-1), and a function that does succeed
49 Sometimes, when \-1 is also a valid successful return value
52 before the call in order to detect possible errors.
54 \fIerrno\fP is defined by the ISO C standard to be a modifiable lvalue
55 of type \fIint\fP, and must not be explicitly declared; \fIerrno\fP
57 \fIerrno\fP is thread-local; setting it in one thread
58 does not affect its value in any other thread.
60 Valid error numbers are all non-zero; \fIerrno\fP is never set to zero
61 by any library function.
62 All the error names specified by POSIX.1
63 must have distinct values, with the exception of
67 which may be the same.
69 .\" The following is now
70 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
71 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
72 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
73 .\" coding errors in multibyte or wide characters.
75 Below is a list of the symbolic error names that are defined on Linux.
76 Some of these are marked
78 indicating that the name is defined by POSIX.1-2001, or
80 indicating that the name is defined by C99.
83 Argument list too long (POSIX.1)
86 Permission denied (POSIX.1)
89 Address already in use (POSIX.1)
92 Address not available (POSIX.1)
93 .\" EADV is only an error on HURD(?)
96 Address family not supported (POSIX.1)
99 Resource temporarily unavailable (may be the same value as
104 Connection already in progress (POSIX.1)
110 Bad file descriptor (POSIX.1)
113 File descriptor in bad state
116 Bad message (POSIX.1)
119 Invalid request descriptor
126 .\" EBFONT is defined but appears not to be used by kernel or glibc.
129 Device or resource busy (POSIX.1)
132 Operation canceled (POSIX.1)
135 No child processes (POSIX.1)
138 Channel number out of range
141 Communication error on send
144 Connection aborted (POSIX.1)
147 Connection refused (POSIX.1)
150 Connection reset (POSIX.1)
153 Resource deadlock avoided (POSIX.1)
160 Destination address required (POSIX.1)
163 Mathematics argument out of domain of function (POSIX.1, C99)
164 .\" EDOTDOT is defined but appears to be unused
167 .\" POSIX just says "Reserved"
168 Disk quota exceeded (POSIX.1)
171 File exists (POSIX.1)
174 Bad address (POSIX.1)
177 File too large (POSIX.1)
183 Host is unreachable (POSIX.1)
186 Identifier removed (POSIX.1)
189 Illegal byte sequence (POSIX.1, C99)
192 Operation in progress (POSIX.1)
195 Interrupted function call (POSIX.1); see
199 Invalid argument (POSIX.1)
202 Input/output error (POSIX.1)
205 Socket is connected (POSIX.1)
208 Is a directory (POSIX.1)
217 Key was rejected by service
226 Level 2 not synchronized
235 Cannot access a needed shared library
238 Accessing a corrupted shared library
241 Attempting to link in too many shared libraries
244 lib section in a.out corrupted
247 Cannot exec a shared library directly
250 Too many levels of symbolic links (POSIX.1)
251 .\" ELNRNG is defined but appears to be unused
257 Too many open files (POSIX.1)
260 Too many links (POSIX.1)
263 Message too long (POSIX.1)
266 .\" POSIX says "Reserved"
267 Multihop attempted (POSIX.1)
270 Filename too long (POSIX.1)
271 .\" ENAVAIL is defined, but appears not to be used
274 Network is down (POSIX.1)
277 Connection aborted by network (POSIX.1)
280 Network unreachable (POSIX.1)
283 Too many open files in system (POSIX.1)
284 .\" ENOANO is defined but appears to be unused.
287 No buffer space available (POSIX.1 (XSI STREAMS option))
288 .\" ENOCSI is defined but appears to be unused.
291 No message is available on the STREAM head read queue (POSIX.1)
294 No such device (POSIX.1)
297 No such file or directory (POSIX.1)
300 Exec format error (POSIX.1)
303 Required key not available
306 No locks available (POSIX.1)
309 .\" POSIX says "Reserved"
310 Link has been severed (POSIX.1)
316 Not enough space (POSIX.1)
319 No message of the desired type (POSIX.1)
322 Machine is not on the network
325 Package not installed
328 Protocol not available (POSIX.1)
331 No space left on device (POSIX.1)
334 No STREAM resources (POSIX.1 (XSI STREAMS option))
337 Not a STREAM (POSIX.1 (XSI STREAMS option))
340 Function not implemented (POSIX.1)
343 Block device required
346 The socket is not connected (POSIX.1)
349 Not a directory (POSIX.1)
352 Directory not empty (POSIX.1)
353 .\" ENOTNAM is defined but appears to be unused.
356 Not a socket (POSIX.1)
359 Operation not supported (POSIX.1)
362 Inappropriate I/O control operation (POSIX.1)
365 Name not unique on network
368 No such device or address (POSIX.1)
371 Operation not supported on socket (POSIX.1)
376 have the same value on Linux, but
377 according to POSIX.1 these error values should be distinct.)
380 Value too large to be stored in data type (POSIX.1)
383 Operation not permitted (POSIX.1)
386 Protocol family not supported
389 Broken pipe (POSIX.1)
392 Protocol error (POSIX.1)
395 Protocol not supported (POSIX.1)
398 Protocol wrong type for socket (POSIX.1)
401 Result too large (POSIX.1, C99)
404 Remote address changed
413 Interrupted system call should be restarted
416 Read-only file system (POSIX.1)
419 Cannot send after transport endpoint shutdown
422 Invalid seek (POSIX.1)
425 Socket type not supported
428 No such process (POSIX.1)
429 .\" ESRMNT is defined but appears not to be used
432 Stale file handle (POSIX.1)
434 This error can occur for NFS and for other file systems
441 (POSIX.1 (XSI STREAMS option))
443 (POSIX.1 says "STREAM
448 Connection timed out (POSIX.1)
449 .\" ETOOMANYREFS is defined, but appears not to be used.
452 Text file busy (POSIX.1)
455 Structure needs cleaning
458 Protocol driver not attached
464 Operation would block (may be same value as
469 Improper link (POSIX.1)
474 A common mistake is to do
478 if (somecall() == \-1) {
479 printf("somecall() failed\en");
480 if (errno == ...) { ... }
487 no longer needs to have the value it had upon return from
489 (i.e., it may have been changed by the
493 should be preserved across a library call, it must be saved:
497 if (somecall() == \-1) {
499 printf("somecall() failed\en");
500 if (errsv == ...) { ... }
505 It was common in traditional C to declare
509 .IR "extern int errno" )
512 .BR "Do not do this" .
513 It will not work with modern versions of the C library.
514 However, on (very) old Unix systems, there may be no
516 and the declaration is needed.