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 2021-03-22 "" "Linux Programmer's Manual"
33 errno \- number of last error
38 .\".BI "extern int " errno ;
43 header file defines the integer variable
45 which is set by system calls and some library functions in the event
46 of an error to indicate what went wrong.
51 is significant only when the return value of
52 the call indicated an error
53 (i.e., \-1 from most system calls;
54 \-1 or NULL from most library functions);
55 a function that succeeds
61 is never set to zero by any system call or library function.
63 For some system calls and library functions (e.g.,
65 \-1 is a valid return on success.
66 In such cases, a successful return can be distinguished from an error
69 to zero before the call, and then,
70 if the call returns a status that indicates that an error
71 may have occurred, checking to see if
76 is defined by the ISO C standard to be a modifiable lvalue
79 and must not be explicitly declared;
83 is thread-local; setting it in one thread
84 does not affect its value in any other thread.
86 .SS Error numbers and names
87 Valid error numbers are all positive numbers.
90 header file defines symbolic names for each
91 of the possible error numbers that may appear in
94 All the error names specified by POSIX.1
95 must have distinct values, with the exception of
99 which may be the same.
100 On Linux, these two have the same value on all architectures.
102 The error numbers that correspond to each symbolic name
103 vary across UNIX systems,
104 and even across different architectures on Linux.
105 Therefore, numeric values are not included as part of the list of
111 functions can be used to convert these names to
112 corresponding textual error messages.
114 On any particular Linux system,
115 one can obtain a list of all symbolic error names and
116 the corresponding error numbers using the
125 EPERM 1 Operation not permitted
126 ENOENT 2 No such file or directory
127 ESRCH 3 No such process
128 EINTR 4 Interrupted system call
129 EIO 5 Input/output error
136 command can also be used to look up individual error numbers and names,
137 and to search for errors using strings from the error description,
138 as in the following examples:
143 ENOENT 2 No such file or directory
145 ESRCH 3 No such process
146 $ \fBerrno \-s permission\fP
147 EACCES 13 Permission denied
151 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
152 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
153 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
154 .\" coding errors in multibyte or wide characters.
156 .SS List of error names
157 In the list of the symbolic error names below,
158 various names are marked as follows:
161 The name is defined by POSIX.1-2001,
162 and is defined in later POSIX.1 versions, unless otherwise indicated.
165 The name is defined in POSIX.1-2008,
166 but was not present in earlier POSIX.1 standards.
169 The name is defined by C99.
171 Below is a list of the symbolic error names that are defined on Linux:
174 Argument list too long (POSIX.1-2001).
177 Permission denied (POSIX.1-2001).
180 Address already in use (POSIX.1-2001).
183 Address not available (POSIX.1-2001).
184 .\" EADV is only an error on HURD(?)
187 Address family not supported (POSIX.1-2001).
190 Resource temporarily unavailable (may be the same value as
195 Connection already in progress (POSIX.1-2001).
201 Bad file descriptor (POSIX.1-2001).
204 File descriptor in bad state.
207 Bad message (POSIX.1-2001).
210 Invalid request descriptor.
213 Invalid request code.
217 .\" EBFONT is defined but appears not to be used by kernel or glibc.
220 Device or resource busy (POSIX.1-2001).
223 Operation canceled (POSIX.1-2001).
226 No child processes (POSIX.1-2001).
229 Channel number out of range.
232 Communication error on send.
235 Connection aborted (POSIX.1-2001).
238 Connection refused (POSIX.1-2001).
241 Connection reset (POSIX.1-2001).
244 Resource deadlock avoided (POSIX.1-2001).
247 On most architectures, a synonym for
249 On some architectures (e.g., Linux MIPS, PowerPC, SPARC),
250 it is a separate error code "File locking deadlock error".
253 Destination address required (POSIX.1-2001).
256 Mathematics argument out of domain of function (POSIX.1, C99).
257 .\" EDOTDOT is defined but appears to be unused
260 .\" POSIX just says "Reserved"
261 Disk quota exceeded (POSIX.1-2001).
264 File exists (POSIX.1-2001).
267 Bad address (POSIX.1-2001).
270 File too large (POSIX.1-2001).
276 Host is unreachable (POSIX.1-2001).
279 Memory page has hardware error.
282 Identifier removed (POSIX.1-2001).
285 Invalid or incomplete multibyte or wide character (POSIX.1, C99).
287 The text shown here is the glibc error description;
288 in POSIX.1, this error is described as "Illegal byte sequence".
291 Operation in progress (POSIX.1-2001).
294 Interrupted function call (POSIX.1-2001); see
298 Invalid argument (POSIX.1-2001).
301 Input/output error (POSIX.1-2001).
304 Socket is connected (POSIX.1-2001).
307 Is a directory (POSIX.1-2001).
310 Is a named type file.
316 Key was rejected by service.
319 Key has been revoked.
325 Level 2 not synchronized.
334 Cannot access a needed shared library.
337 Accessing a corrupted shared library.
340 Attempting to link in too many shared libraries.
343 \&.lib section in a.out corrupted
346 Cannot exec a shared library directly.
349 .\" ELNRNG appears to be used by a few drivers
350 Link number out of range.
353 Too many levels of symbolic links (POSIX.1-2001).
359 Too many open files (POSIX.1-2001).
360 Commonly caused by exceeding the
362 resource limit described in
364 Can also be caused by exceeding the limit specified in
365 .IR /proc/sys/fs/nr_open .
368 Too many links (POSIX.1-2001).
371 Message too long (POSIX.1-2001).
374 .\" POSIX says "Reserved"
375 Multihop attempted (POSIX.1-2001).
378 Filename too long (POSIX.1-2001).
379 .\" ENAVAIL is defined, but appears not to be used
382 Network is down (POSIX.1-2001).
385 Connection aborted by network (POSIX.1-2001).
388 Network unreachable (POSIX.1-2001).
391 Too many open files in system (POSIX.1-2001).
392 On Linux, this is probably a result of encountering the
393 .IR /proc/sys/fs/file\-max
398 .\" ENOANO appears to be used by a few drivers
402 No buffer space available (POSIX.1 (XSI STREAMS option)).
403 .\" ENOCSI is defined but appears to be unused.
406 The named attribute does not exist,
407 or the process has no access to this attribute; see
410 In POSIX.1-2001 (XSI STREAMS option),
411 this error was described as
412 "No message is available on the STREAM head read queue".
415 No such device (POSIX.1-2001).
418 No such file or directory (POSIX.1-2001).
420 Typically, this error results when a specified pathname does not exist,
421 or one of the components in the directory prefix of a pathname does not exist,
422 or the specified pathname is a dangling symbolic link.
425 Exec format error (POSIX.1-2001).
428 Required key not available.
431 No locks available (POSIX.1-2001).
434 .\" POSIX says "Reserved"
435 Link has been severed (POSIX.1-2001).
441 Not enough space/cannot allocate memory (POSIX.1-2001).
444 No message of the desired type (POSIX.1-2001).
447 Machine is not on the network.
450 Package not installed.
453 Protocol not available (POSIX.1-2001).
456 No space left on device (POSIX.1-2001).
459 No STREAM resources (POSIX.1 (XSI STREAMS option)).
462 Not a STREAM (POSIX.1 (XSI STREAMS option)).
465 Function not implemented (POSIX.1-2001).
468 Block device required.
471 The socket is not connected (POSIX.1-2001).
474 Not a directory (POSIX.1-2001).
477 Directory not empty (POSIX.1-2001).
478 .\" ENOTNAM is defined but appears to be unused.
481 State not recoverable (POSIX.1-2008).
484 Not a socket (POSIX.1-2001).
487 Operation not supported (POSIX.1-2001).
490 Inappropriate I/O control operation (POSIX.1-2001).
493 Name not unique on network.
496 No such device or address (POSIX.1-2001).
499 Operation not supported on socket (POSIX.1-2001).
504 have the same value on Linux, but
505 according to POSIX.1 these error values should be distinct.)
508 Value too large to be stored in data type (POSIX.1-2001).
511 .\" Used at least by the user-space side of rubost mutexes
512 Owner died (POSIX.1-2008).
515 Operation not permitted (POSIX.1-2001).
518 Protocol family not supported.
521 Broken pipe (POSIX.1-2001).
524 Protocol error (POSIX.1-2001).
527 Protocol not supported (POSIX.1-2001).
530 Protocol wrong type for socket (POSIX.1-2001).
533 Result too large (POSIX.1, C99).
536 Remote address changed.
545 Interrupted system call should be restarted.
548 .\" ERFKILL appears to be used by various drivers
549 Operation not possible due to RF-kill.
552 Read-only filesystem (POSIX.1-2001).
555 Cannot send after transport endpoint shutdown.
558 Invalid seek (POSIX.1-2001).
561 Socket type not supported.
564 No such process (POSIX.1-2001).
565 .\" ESRMNT is defined but appears not to be used
568 Stale file handle (POSIX.1-2001).
570 This error can occur for NFS and for other filesystems.
577 (POSIX.1 (XSI STREAMS option)).
579 (POSIX.1 says "STREAM
584 Connection timed out (POSIX.1-2001).
587 .\" ETOOMANYREFS seems to be used in net/unix/af_unix.c
588 Too many references: cannot splice.
591 Text file busy (POSIX.1-2001).
594 Structure needs cleaning.
597 Protocol driver not attached.
603 Operation would block (may be same value as
608 Improper link (POSIX.1-2001).
613 A common mistake is to do
617 if (somecall() == \-1) {
618 printf("somecall() failed\en");
619 if (errno == ...) { ... }
626 no longer needs to have the value it had upon return from
628 (i.e., it may have been changed by the
632 should be preserved across a library call, it must be saved:
636 if (somecall() == \-1) {
638 printf("somecall() failed\en");
639 if (errsv == ...) { ... }
644 Note that the POSIX threads APIs do
649 Instead, on failure they return an error number as the function result.
650 These error numbers have the same meanings as the error numbers returned in
654 On some ancient systems,
656 was not present or did not declare
658 so that it was necessary to declare
662 .IR "extern int errno" ).
663 .BR "Do not do this" .
664 It long ago ceased to be necessary,
665 and it will cause problems with modern versions of the C library.
667 .BR errno (1), \" In the moreutils package