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 2017-09-15 "" "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.
49 is significant only when the return value of
50 the call indicated an error
51 (i.e., \-1 from most system calls;
52 \-1 or NULL from most library functions);
53 a function that succeeds
59 is never set to zero by any system call or library function.
61 For some system calls and library functions (e.g.,
63 \-1 is a valid return on success.
64 In such cases, a successful return can be distinguished from an error
67 to zero before the call, and then,
68 if the call returns a status that indicates that an error
69 may have occurred, checking to see if
74 is defined by the ISO C standard to be a modifiable lvalue
77 and must not be explicitly declared;
81 is thread-local; setting it in one thread
82 does not affect its value in any other thread.
84 .SS Error numbers and names
85 Valid error numbers are all positive numbers.
88 header file defines symbolic names for each
89 of the possible error numbers that may appear in
92 All the error names specified by POSIX.1
93 must have distinct values, with the exception of
97 which may be the same.
99 On Linux, the error numbers that correspond to each symbolic name
100 vary somewhat across architectures.
101 Therefore, numeric values are not included in the list of
103 On any particular system,
104 one can obtain a list of all symbolic error names and
105 the corresponding error numbers using the
112 EPERM 1 Operation not permitted
113 ENOENT 2 No such file or directory
114 ESRCH 3 No such process
115 EINTR 4 Interrupted system call
116 EIO 5 Input/output error
123 command can also be used to look up individual error numbers and names
124 as in the following examples:
129 ENOENT 2 No such file or directory
131 ESRCH 3 No such process
135 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
136 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
137 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
138 .\" coding errors in multibyte or wide characters.
140 .SS List of error names
141 In the list of the symbolic error names below,
142 various names are marked as follows:
145 The name is defined by POSIX.1-2001,
146 and is defined in later POSIX.1 versions, unless otherwise indicated.
149 The name is defined in POSIX.1-2008,
150 but was not present in earlier POSIX.1 standards.
153 The name is defined by C99.
154 Below is a list of the symbolic error names that are defined on Linux:
157 Argument list too long (POSIX.1-2001).
160 Permission denied (POSIX.1-2001).
163 Address already in use (POSIX.1-2001).
166 Address not available (POSIX.1-2001).
167 .\" EADV is only an error on HURD(?)
170 Address family not supported (POSIX.1-2001).
173 Resource temporarily unavailable (may be the same value as
178 Connection already in progress (POSIX.1-2001).
184 Bad file descriptor (POSIX.1-2001).
187 File descriptor in bad state.
190 Bad message (POSIX.1-2001).
193 Invalid request descriptor.
196 Invalid request code.
200 .\" EBFONT is defined but appears not to be used by kernel or glibc.
203 Device or resource busy (POSIX.1-2001).
206 Operation canceled (POSIX.1-2001).
209 No child processes (POSIX.1-2001).
212 Channel number out of range.
215 Communication error on send.
218 Connection aborted (POSIX.1-2001).
221 Connection refused (POSIX.1-2001).
224 Connection reset (POSIX.1-2001).
227 Resource deadlock avoided (POSIX.1-2001).
234 Destination address required (POSIX.1-2001).
237 Mathematics argument out of domain of function (POSIX.1, C99).
238 .\" EDOTDOT is defined but appears to be unused
241 .\" POSIX just says "Reserved"
242 Disk quota exceeded (POSIX.1-2001).
245 File exists (POSIX.1-2001).
248 Bad address (POSIX.1-2001).
251 File too large (POSIX.1-2001).
257 Host is unreachable (POSIX.1-2001).
260 Memory page has hardware error.
263 Identifier removed (POSIX.1-2001).
266 Invalid or incomplete multibyte or wide character (POSIX.1, C99).
268 The text shown here is the glibc error description;
269 in POSIX.1, this error is described as "Illegal byte sequence".
272 Operation in progress (POSIX.1-2001).
275 Interrupted function call (POSIX.1-2001); see
279 Invalid argument (POSIX.1-2001).
282 Input/output error (POSIX.1-2001).
285 Socket is connected (POSIX.1-2001).
288 Is a directory (POSIX.1-2001).
291 Is a named type file.
297 Key was rejected by service.
300 Key has been revoked.
306 Level 2 not synchronized.
315 Cannot access a needed shared library.
318 Accessing a corrupted shared library.
321 Attempting to link in too many shared libraries.
324 \&.lib section in a.out corrupted
327 Cannot exec a shared library directly.
330 .\" ELNRNG appears to be used by a few drivers
331 Link number out of range.
334 Too many levels of symbolic links (POSIX.1-2001).
340 Too many open files (POSIX.1-2001).
341 Commonly caused by exceeding the
343 resource limit described in
347 Too many links (POSIX.1-2001).
350 Message too long (POSIX.1-2001).
353 .\" POSIX says "Reserved"
354 Multihop attempted (POSIX.1-2001).
357 Filename too long (POSIX.1-2001).
358 .\" ENAVAIL is defined, but appears not to be used
361 Network is down (POSIX.1-2001).
364 Connection aborted by network (POSIX.1-2001).
367 Network unreachable (POSIX.1-2001).
370 Too many open files in system (POSIX.1-2001).
371 On Linux, this is probably a result of encountering the
372 .IR /proc/sys/fs/file-max
377 .\" ENOANO appears to be used by a few drivers
381 No buffer space available (POSIX.1 (XSI STREAMS option)).
382 .\" ENOCSI is defined but appears to be unused.
385 No message is available on the STREAM head read queue (POSIX.1-2001).
388 No such device (POSIX.1-2001).
391 No such file or directory (POSIX.1-2001).
393 Typically, this error results when a specified pathname does not exist,
394 or one of the components in the directory prefix of a pathname does not exist,
395 or the specified pathname is a dangling symbolic link.
398 Exec format error (POSIX.1-2001).
401 Required key not available.
404 No locks available (POSIX.1-2001).
407 .\" POSIX says "Reserved"
408 Link has been severed (POSIX.1-2001).
414 Not enough space (POSIX.1-2001).
417 No message of the desired type (POSIX.1-2001).
420 Machine is not on the network.
423 Package not installed.
426 Protocol not available (POSIX.1-2001).
429 No space left on device (POSIX.1-2001).
432 No STREAM resources (POSIX.1 (XSI STREAMS option)).
435 Not a STREAM (POSIX.1 (XSI STREAMS option)).
438 Function not implemented (POSIX.1-2001).
441 Block device required.
444 The socket is not connected (POSIX.1-2001).
447 Not a directory (POSIX.1-2001).
450 Directory not empty (POSIX.1-2001).
451 .\" ENOTNAM is defined but appears to be unused.
454 State not recoverable (POSIX.1-2008).
457 Not a socket (POSIX.1-2001).
460 Operation not supported (POSIX.1-2001).
463 Inappropriate I/O control operation (POSIX.1-2001).
466 Name not unique on network.
469 No such device or address (POSIX.1-2001).
472 Operation not supported on socket (POSIX.1-2001).
477 have the same value on Linux, but
478 according to POSIX.1 these error values should be distinct.)
481 Value too large to be stored in data type (POSIX.1-2001).
484 .\" Used at least by the user-space side of rubost mutexes
485 Owner died (POSIX.1-2008).
488 Operation not permitted (POSIX.1-2001).
491 Protocol family not supported.
494 Broken pipe (POSIX.1-2001).
497 Protocol error (POSIX.1-2001).
500 Protocol not supported (POSIX.1-2001).
503 Protocol wrong type for socket (POSIX.1-2001).
506 Result too large (POSIX.1, C99).
509 Remote address changed.
518 Interrupted system call should be restarted.
521 .\" ERFKILL appears to be used by various drivers
522 Operation not possible due to RF-kill.
525 Read-only filesystem (POSIX.1-2001).
528 Cannot send after transport endpoint shutdown.
531 Invalid seek (POSIX.1-2001).
534 Socket type not supported.
537 No such process (POSIX.1-2001).
538 .\" ESRMNT is defined but appears not to be used
541 Stale file handle (POSIX.1-2001).
543 This error can occur for NFS and for other filesystems.
550 (POSIX.1 (XSI STREAMS option)).
552 (POSIX.1 says "STREAM
557 Connection timed out (POSIX.1-2001).
560 .\" ETOOMANYREFS seems to be used in net/unix/af_unix.c
561 Too many references: cannot splice.
564 Text file busy (POSIX.1-2001).
567 Structure needs cleaning.
570 Protocol driver not attached.
576 Operation would block (may be same value as
581 Improper link (POSIX.1-2001).
586 A common mistake is to do
590 if (somecall() == \-1) {
591 printf("somecall() failed\en");
592 if (errno == ...) { ... }
599 no longer needs to have the value it had upon return from
601 (i.e., it may have been changed by the
605 should be preserved across a library call, it must be saved:
609 if (somecall() == \-1) {
611 printf("somecall() failed\en");
612 if (errsv == ...) { ... }
617 It was common in traditional C to declare
621 .IR "extern int errno" )
624 .BR "Do not do this" .
625 It will not work with modern versions of the C library.
626 However, on (very) old UNIX systems, there may be no
628 and the declaration is needed.
630 .BR errno (1), \" In the moreutils package