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 2015-12-28 "" "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;
57 by any system call or library function.
59 For some system calls and library functions (e.g.,
61 \-1 is a valid return on success.
62 In such cases, a successful return can be distinguished from an error
65 to zero before the call, and then,
66 if the call returns a status that indicates that an error
67 may have occurred, checking to see if
72 is defined by the ISO C standard to be a modifiable lvalue
75 and must not be explicitly declared;
79 is thread-local; setting it in one thread
80 does not affect its value in any other thread.
82 All the error names specified by POSIX.1
83 must have distinct values, with the exception of
87 which may be the same.
89 .\" The following is now
90 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
91 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
92 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
93 .\" coding errors in multibyte or wide characters.
95 Below is a list of the symbolic error names that are defined on Linux.
96 Some of these are marked
98 indicating that the name is defined by POSIX.1-2001, or
99 .\" FIXME This list should be updated for POSIX.1-2008
101 indicating that the name is defined by C99.
104 Argument list too long (POSIX.1)
107 Permission denied (POSIX.1)
110 Address already in use (POSIX.1)
113 Address not available (POSIX.1)
114 .\" EADV is only an error on HURD(?)
117 Address family not supported (POSIX.1)
120 Resource temporarily unavailable (may be the same value as
125 Connection already in progress (POSIX.1)
131 Bad file descriptor (POSIX.1)
134 File descriptor in bad state
137 Bad message (POSIX.1)
140 Invalid request descriptor
147 .\" EBFONT is defined but appears not to be used by kernel or glibc.
150 Device or resource busy (POSIX.1)
153 Operation canceled (POSIX.1)
156 No child processes (POSIX.1)
159 Channel number out of range
162 Communication error on send
165 Connection aborted (POSIX.1)
168 Connection refused (POSIX.1)
171 Connection reset (POSIX.1)
174 Resource deadlock avoided (POSIX.1)
181 Destination address required (POSIX.1)
184 Mathematics argument out of domain of function (POSIX.1, C99)
185 .\" EDOTDOT is defined but appears to be unused
188 .\" POSIX just says "Reserved"
189 Disk quota exceeded (POSIX.1)
192 File exists (POSIX.1)
195 Bad address (POSIX.1)
198 File too large (POSIX.1)
204 Host is unreachable (POSIX.1)
207 Identifier removed (POSIX.1)
210 Illegal byte sequence (POSIX.1, C99)
213 Operation in progress (POSIX.1)
216 Interrupted function call (POSIX.1); see
220 Invalid argument (POSIX.1)
223 Input/output error (POSIX.1)
226 Socket is connected (POSIX.1)
229 Is a directory (POSIX.1)
238 Key was rejected by service
247 Level 2 not synchronized
256 Cannot access a needed shared library
259 Accessing a corrupted shared library
262 Attempting to link in too many shared libraries
265 lib section in a.out corrupted
268 Cannot exec a shared library directly
271 Too many levels of symbolic links (POSIX.1)
272 .\" ELNRNG is defined but appears to be unused
278 Too many open files (POSIX.1);
279 commonly caused by exceeding the
281 resource limit described in
285 Too many links (POSIX.1)
288 Message too long (POSIX.1)
291 .\" POSIX says "Reserved"
292 Multihop attempted (POSIX.1)
295 Filename too long (POSIX.1)
296 .\" ENAVAIL is defined, but appears not to be used
299 Network is down (POSIX.1)
302 Connection aborted by network (POSIX.1)
305 Network unreachable (POSIX.1)
308 Too many open files in system (POSIX.1);
309 on Linux, this is probably a result of encountering the
310 .IR /proc/sys/fs/file-max
313 .\" ENOANO is defined but appears to be unused.
316 No buffer space available (POSIX.1 (XSI STREAMS option))
317 .\" ENOCSI is defined but appears to be unused.
320 No message is available on the STREAM head read queue (POSIX.1)
323 No such device (POSIX.1)
326 No such file or directory (POSIX.1)
328 Typically, this error results when a specified pathname does not exist,
329 or one of the components in the directory prefix of a pathname does not exist,
330 or the specified pathname is a dangling symbolic link.
333 Exec format error (POSIX.1)
336 Required key not available
339 No locks available (POSIX.1)
342 .\" POSIX says "Reserved"
343 Link has been severed (POSIX.1)
349 Not enough space (POSIX.1)
352 No message of the desired type (POSIX.1)
355 Machine is not on the network
358 Package not installed
361 Protocol not available (POSIX.1)
364 No space left on device (POSIX.1)
367 No STREAM resources (POSIX.1 (XSI STREAMS option))
370 Not a STREAM (POSIX.1 (XSI STREAMS option))
373 Function not implemented (POSIX.1)
376 Block device required
379 The socket is not connected (POSIX.1)
382 Not a directory (POSIX.1)
385 Directory not empty (POSIX.1)
386 .\" ENOTNAM is defined but appears to be unused.
389 Not a socket (POSIX.1)
392 Operation not supported (POSIX.1)
395 Inappropriate I/O control operation (POSIX.1)
398 Name not unique on network
401 No such device or address (POSIX.1)
404 Operation not supported on socket (POSIX.1)
409 have the same value on Linux, but
410 according to POSIX.1 these error values should be distinct.)
413 Value too large to be stored in data type (POSIX.1)
416 Operation not permitted (POSIX.1)
419 Protocol family not supported
422 Broken pipe (POSIX.1)
425 Protocol error (POSIX.1)
428 Protocol not supported (POSIX.1)
431 Protocol wrong type for socket (POSIX.1)
434 Result too large (POSIX.1, C99)
437 Remote address changed
446 Interrupted system call should be restarted
449 Read-only filesystem (POSIX.1)
452 Cannot send after transport endpoint shutdown
455 Invalid seek (POSIX.1)
458 Socket type not supported
461 No such process (POSIX.1)
462 .\" ESRMNT is defined but appears not to be used
465 Stale file handle (POSIX.1)
467 This error can occur for NFS and for other filesystems
474 (POSIX.1 (XSI STREAMS option))
476 (POSIX.1 says "STREAM
481 Connection timed out (POSIX.1)
482 .\" ETOOMANYREFS is defined, but appears not to be used.
485 Text file busy (POSIX.1)
488 Structure needs cleaning
491 Protocol driver not attached
497 Operation would block (may be same value as
502 Improper link (POSIX.1)
507 A common mistake is to do
511 if (somecall() == \-1) {
512 printf("somecall() failed\en");
513 if (errno == ...) { ... }
520 no longer needs to have the value it had upon return from
522 (i.e., it may have been changed by the
526 should be preserved across a library call, it must be saved:
530 if (somecall() == \-1) {
532 printf("somecall() failed\en");
533 if (errsv == ...) { ... }
538 It was common in traditional C to declare
542 .IR "extern int errno" )
545 .BR "Do not do this" .
546 It will not work with modern versions of the C library.
547 However, on (very) old UNIX systems, there may be no
549 and the declaration is needed.
551 .BR errno (1), \" In the moreutils package