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 2019-10-10 "" "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.
98 On Linux, these two have the same value on all architectures.
100 The error numbers that correspond to each symbolic name
101 vary across UNIX systems,
102 and even across different architectures on Linux.
103 Therefore, numeric values are not included as part of the list of
109 functions can be used to convert these names to
110 corresponding textual error messages.
112 On any particular Linux system,
113 one can obtain a list of all symbolic error names and
114 the corresponding error numbers using the
123 EPERM 1 Operation not permitted
124 ENOENT 2 No such file or directory
125 ESRCH 3 No such process
126 EINTR 4 Interrupted system call
127 EIO 5 Input/output error
134 command can also be used to look up individual error numbers and names,
135 and to search for errors using strings from the error description,
136 as in the following examples:
141 ENOENT 2 No such file or directory
143 ESRCH 3 No such process
144 $ \fBerrno \-s permission\fP
145 EACCES 13 Permission denied
149 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
150 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
151 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
152 .\" coding errors in multibyte or wide characters.
154 .SS List of error names
155 In the list of the symbolic error names below,
156 various names are marked as follows:
159 The name is defined by POSIX.1-2001,
160 and is defined in later POSIX.1 versions, unless otherwise indicated.
163 The name is defined in POSIX.1-2008,
164 but was not present in earlier POSIX.1 standards.
167 The name is defined by C99.
169 Below is a list of the symbolic error names that are defined on Linux:
172 Argument list too long (POSIX.1-2001).
175 Permission denied (POSIX.1-2001).
178 Address already in use (POSIX.1-2001).
181 Address not available (POSIX.1-2001).
182 .\" EADV is only an error on HURD(?)
185 Address family not supported (POSIX.1-2001).
188 Resource temporarily unavailable (may be the same value as
193 Connection already in progress (POSIX.1-2001).
199 Bad file descriptor (POSIX.1-2001).
202 File descriptor in bad state.
205 Bad message (POSIX.1-2001).
208 Invalid request descriptor.
211 Invalid request code.
215 .\" EBFONT is defined but appears not to be used by kernel or glibc.
218 Device or resource busy (POSIX.1-2001).
221 Operation canceled (POSIX.1-2001).
224 No child processes (POSIX.1-2001).
227 Channel number out of range.
230 Communication error on send.
233 Connection aborted (POSIX.1-2001).
236 Connection refused (POSIX.1-2001).
239 Connection reset (POSIX.1-2001).
242 Resource deadlock avoided (POSIX.1-2001).
245 On most architectures, a synonym for
247 On some architectures (e.g., Linux MIPS, PowerPC, SPARC),
248 it is a separate error code "File locking deadlock error".
251 Destination address required (POSIX.1-2001).
254 Mathematics argument out of domain of function (POSIX.1, C99).
255 .\" EDOTDOT is defined but appears to be unused
258 .\" POSIX just says "Reserved"
259 Disk quota exceeded (POSIX.1-2001).
262 File exists (POSIX.1-2001).
265 Bad address (POSIX.1-2001).
268 File too large (POSIX.1-2001).
274 Host is unreachable (POSIX.1-2001).
277 Memory page has hardware error.
280 Identifier removed (POSIX.1-2001).
283 Invalid or incomplete multibyte or wide character (POSIX.1, C99).
285 The text shown here is the glibc error description;
286 in POSIX.1, this error is described as "Illegal byte sequence".
289 Operation in progress (POSIX.1-2001).
292 Interrupted function call (POSIX.1-2001); see
296 Invalid argument (POSIX.1-2001).
299 Input/output error (POSIX.1-2001).
302 Socket is connected (POSIX.1-2001).
305 Is a directory (POSIX.1-2001).
308 Is a named type file.
314 Key was rejected by service.
317 Key has been revoked.
323 Level 2 not synchronized.
332 Cannot access a needed shared library.
335 Accessing a corrupted shared library.
338 Attempting to link in too many shared libraries.
341 \&.lib section in a.out corrupted
344 Cannot exec a shared library directly.
347 .\" ELNRNG appears to be used by a few drivers
348 Link number out of range.
351 Too many levels of symbolic links (POSIX.1-2001).
357 Too many open files (POSIX.1-2001).
358 Commonly caused by exceeding the
360 resource limit described in
364 Too many links (POSIX.1-2001).
367 Message too long (POSIX.1-2001).
370 .\" POSIX says "Reserved"
371 Multihop attempted (POSIX.1-2001).
374 Filename too long (POSIX.1-2001).
375 .\" ENAVAIL is defined, but appears not to be used
378 Network is down (POSIX.1-2001).
381 Connection aborted by network (POSIX.1-2001).
384 Network unreachable (POSIX.1-2001).
387 Too many open files in system (POSIX.1-2001).
388 On Linux, this is probably a result of encountering the
389 .IR /proc/sys/fs/file-max
394 .\" ENOANO appears to be used by a few drivers
398 No buffer space available (POSIX.1 (XSI STREAMS option)).
399 .\" ENOCSI is defined but appears to be unused.
402 No message is available on the STREAM head read queue (POSIX.1-2001).
405 No such device (POSIX.1-2001).
408 No such file or directory (POSIX.1-2001).
410 Typically, this error results when a specified pathname does not exist,
411 or one of the components in the directory prefix of a pathname does not exist,
412 or the specified pathname is a dangling symbolic link.
415 Exec format error (POSIX.1-2001).
418 Required key not available.
421 No locks available (POSIX.1-2001).
424 .\" POSIX says "Reserved"
425 Link has been severed (POSIX.1-2001).
431 Not enough space/cannot allocate memory (POSIX.1-2001).
434 No message of the desired type (POSIX.1-2001).
437 Machine is not on the network.
440 Package not installed.
443 Protocol not available (POSIX.1-2001).
446 No space left on device (POSIX.1-2001).
449 No STREAM resources (POSIX.1 (XSI STREAMS option)).
452 Not a STREAM (POSIX.1 (XSI STREAMS option)).
455 Function not implemented (POSIX.1-2001).
458 Block device required.
461 The socket is not connected (POSIX.1-2001).
464 Not a directory (POSIX.1-2001).
467 Directory not empty (POSIX.1-2001).
468 .\" ENOTNAM is defined but appears to be unused.
471 State not recoverable (POSIX.1-2008).
474 Not a socket (POSIX.1-2001).
477 Operation not supported (POSIX.1-2001).
480 Inappropriate I/O control operation (POSIX.1-2001).
483 Name not unique on network.
486 No such device or address (POSIX.1-2001).
489 Operation not supported on socket (POSIX.1-2001).
494 have the same value on Linux, but
495 according to POSIX.1 these error values should be distinct.)
498 Value too large to be stored in data type (POSIX.1-2001).
501 .\" Used at least by the user-space side of rubost mutexes
502 Owner died (POSIX.1-2008).
505 Operation not permitted (POSIX.1-2001).
508 Protocol family not supported.
511 Broken pipe (POSIX.1-2001).
514 Protocol error (POSIX.1-2001).
517 Protocol not supported (POSIX.1-2001).
520 Protocol wrong type for socket (POSIX.1-2001).
523 Result too large (POSIX.1, C99).
526 Remote address changed.
535 Interrupted system call should be restarted.
538 .\" ERFKILL appears to be used by various drivers
539 Operation not possible due to RF-kill.
542 Read-only filesystem (POSIX.1-2001).
545 Cannot send after transport endpoint shutdown.
548 Invalid seek (POSIX.1-2001).
551 Socket type not supported.
554 No such process (POSIX.1-2001).
555 .\" ESRMNT is defined but appears not to be used
558 Stale file handle (POSIX.1-2001).
560 This error can occur for NFS and for other filesystems.
567 (POSIX.1 (XSI STREAMS option)).
569 (POSIX.1 says "STREAM
574 Connection timed out (POSIX.1-2001).
577 .\" ETOOMANYREFS seems to be used in net/unix/af_unix.c
578 Too many references: cannot splice.
581 Text file busy (POSIX.1-2001).
584 Structure needs cleaning.
587 Protocol driver not attached.
593 Operation would block (may be same value as
598 Improper link (POSIX.1-2001).
603 A common mistake is to do
607 if (somecall() == \-1) {
608 printf("somecall() failed\en");
609 if (errno == ...) { ... }
616 no longer needs to have the value it had upon return from
618 (i.e., it may have been changed by the
622 should be preserved across a library call, it must be saved:
626 if (somecall() == \-1) {
628 printf("somecall() failed\en");
629 if (errsv == ...) { ... }
634 On some ancient systems,
636 was not present or did not declare
638 so that it was necessary to declare
642 .IR "extern int errno" ).
643 .BR "Do not do this" .
644 It long ago ceased to be necessary,
645 and it will cause problems with modern versions of the C library.
647 .BR errno (1), \" In the moreutils package