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 2018-02-02 "" "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 The error numbers that correspond to each symbolic name
100 vary across UNIX systems,
101 and even across different architectures on Linux.
102 Therefore, numeric values are not included as part of the list of
108 functions can be used to convert these names to
109 corresponding textual error messages.
111 On any particular Linux system,
112 one can obtain a list of all symbolic error names and
113 the corresponding error numbers using the
120 EPERM 1 Operation not permitted
121 ENOENT 2 No such file or directory
122 ESRCH 3 No such process
123 EINTR 4 Interrupted system call
124 EIO 5 Input/output error
131 command can also be used to look up individual error numbers and names,
132 and to search for errors using strings from the error description,
133 as in the following examples:
138 ENOENT 2 No such file or directory
140 ESRCH 3 No such process
141 $ \fBerrno \-s permission\fP
142 EACCES 13 Permission denied
146 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
147 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
148 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
149 .\" coding errors in multibyte or wide characters.
151 .SS List of error names
152 In the list of the symbolic error names below,
153 various names are marked as follows:
156 The name is defined by POSIX.1-2001,
157 and is defined in later POSIX.1 versions, unless otherwise indicated.
160 The name is defined in POSIX.1-2008,
161 but was not present in earlier POSIX.1 standards.
164 The name is defined by C99.
165 Below is a list of the symbolic error names that are defined on Linux:
168 Argument list too long (POSIX.1-2001).
171 Permission denied (POSIX.1-2001).
174 Address already in use (POSIX.1-2001).
177 Address not available (POSIX.1-2001).
178 .\" EADV is only an error on HURD(?)
181 Address family not supported (POSIX.1-2001).
184 Resource temporarily unavailable (may be the same value as
189 Connection already in progress (POSIX.1-2001).
195 Bad file descriptor (POSIX.1-2001).
198 File descriptor in bad state.
201 Bad message (POSIX.1-2001).
204 Invalid request descriptor.
207 Invalid request code.
211 .\" EBFONT is defined but appears not to be used by kernel or glibc.
214 Device or resource busy (POSIX.1-2001).
217 Operation canceled (POSIX.1-2001).
220 No child processes (POSIX.1-2001).
223 Channel number out of range.
226 Communication error on send.
229 Connection aborted (POSIX.1-2001).
232 Connection refused (POSIX.1-2001).
235 Connection reset (POSIX.1-2001).
238 Resource deadlock avoided (POSIX.1-2001).
245 Destination address required (POSIX.1-2001).
248 Mathematics argument out of domain of function (POSIX.1, C99).
249 .\" EDOTDOT is defined but appears to be unused
252 .\" POSIX just says "Reserved"
253 Disk quota exceeded (POSIX.1-2001).
256 File exists (POSIX.1-2001).
259 Bad address (POSIX.1-2001).
262 File too large (POSIX.1-2001).
268 Host is unreachable (POSIX.1-2001).
271 Memory page has hardware error.
274 Identifier removed (POSIX.1-2001).
277 Invalid or incomplete multibyte or wide character (POSIX.1, C99).
279 The text shown here is the glibc error description;
280 in POSIX.1, this error is described as "Illegal byte sequence".
283 Operation in progress (POSIX.1-2001).
286 Interrupted function call (POSIX.1-2001); see
290 Invalid argument (POSIX.1-2001).
293 Input/output error (POSIX.1-2001).
296 Socket is connected (POSIX.1-2001).
299 Is a directory (POSIX.1-2001).
302 Is a named type file.
308 Key was rejected by service.
311 Key has been revoked.
317 Level 2 not synchronized.
326 Cannot access a needed shared library.
329 Accessing a corrupted shared library.
332 Attempting to link in too many shared libraries.
335 \&.lib section in a.out corrupted
338 Cannot exec a shared library directly.
341 .\" ELNRNG appears to be used by a few drivers
342 Link number out of range.
345 Too many levels of symbolic links (POSIX.1-2001).
351 Too many open files (POSIX.1-2001).
352 Commonly caused by exceeding the
354 resource limit described in
358 Too many links (POSIX.1-2001).
361 Message too long (POSIX.1-2001).
364 .\" POSIX says "Reserved"
365 Multihop attempted (POSIX.1-2001).
368 Filename too long (POSIX.1-2001).
369 .\" ENAVAIL is defined, but appears not to be used
372 Network is down (POSIX.1-2001).
375 Connection aborted by network (POSIX.1-2001).
378 Network unreachable (POSIX.1-2001).
381 Too many open files in system (POSIX.1-2001).
382 On Linux, this is probably a result of encountering the
383 .IR /proc/sys/fs/file-max
388 .\" ENOANO appears to be used by a few drivers
392 No buffer space available (POSIX.1 (XSI STREAMS option)).
393 .\" ENOCSI is defined but appears to be unused.
396 No message is available on the STREAM head read queue (POSIX.1-2001).
399 No such device (POSIX.1-2001).
402 No such file or directory (POSIX.1-2001).
404 Typically, this error results when a specified pathname does not exist,
405 or one of the components in the directory prefix of a pathname does not exist,
406 or the specified pathname is a dangling symbolic link.
409 Exec format error (POSIX.1-2001).
412 Required key not available.
415 No locks available (POSIX.1-2001).
418 .\" POSIX says "Reserved"
419 Link has been severed (POSIX.1-2001).
425 Not enough space/cannot allocate memory (POSIX.1-2001).
428 No message of the desired type (POSIX.1-2001).
431 Machine is not on the network.
434 Package not installed.
437 Protocol not available (POSIX.1-2001).
440 No space left on device (POSIX.1-2001).
443 No STREAM resources (POSIX.1 (XSI STREAMS option)).
446 Not a STREAM (POSIX.1 (XSI STREAMS option)).
449 Function not implemented (POSIX.1-2001).
452 Block device required.
455 The socket is not connected (POSIX.1-2001).
458 Not a directory (POSIX.1-2001).
461 Directory not empty (POSIX.1-2001).
462 .\" ENOTNAM is defined but appears to be unused.
465 State not recoverable (POSIX.1-2008).
468 Not a socket (POSIX.1-2001).
471 Operation not supported (POSIX.1-2001).
474 Inappropriate I/O control operation (POSIX.1-2001).
477 Name not unique on network.
480 No such device or address (POSIX.1-2001).
483 Operation not supported on socket (POSIX.1-2001).
488 have the same value on Linux, but
489 according to POSIX.1 these error values should be distinct.)
492 Value too large to be stored in data type (POSIX.1-2001).
495 .\" Used at least by the user-space side of rubost mutexes
496 Owner died (POSIX.1-2008).
499 Operation not permitted (POSIX.1-2001).
502 Protocol family not supported.
505 Broken pipe (POSIX.1-2001).
508 Protocol error (POSIX.1-2001).
511 Protocol not supported (POSIX.1-2001).
514 Protocol wrong type for socket (POSIX.1-2001).
517 Result too large (POSIX.1, C99).
520 Remote address changed.
529 Interrupted system call should be restarted.
532 .\" ERFKILL appears to be used by various drivers
533 Operation not possible due to RF-kill.
536 Read-only filesystem (POSIX.1-2001).
539 Cannot send after transport endpoint shutdown.
542 Invalid seek (POSIX.1-2001).
545 Socket type not supported.
548 No such process (POSIX.1-2001).
549 .\" ESRMNT is defined but appears not to be used
552 Stale file handle (POSIX.1-2001).
554 This error can occur for NFS and for other filesystems.
561 (POSIX.1 (XSI STREAMS option)).
563 (POSIX.1 says "STREAM
568 Connection timed out (POSIX.1-2001).
571 .\" ETOOMANYREFS seems to be used in net/unix/af_unix.c
572 Too many references: cannot splice.
575 Text file busy (POSIX.1-2001).
578 Structure needs cleaning.
581 Protocol driver not attached.
587 Operation would block (may be same value as
592 Improper link (POSIX.1-2001).
597 A common mistake is to do
601 if (somecall() == \-1) {
602 printf("somecall() failed\en");
603 if (errno == ...) { ... }
610 no longer needs to have the value it had upon return from
612 (i.e., it may have been changed by the
616 should be preserved across a library call, it must be saved:
620 if (somecall() == \-1) {
622 printf("somecall() failed\en");
623 if (errsv == ...) { ... }
628 On some ancient systems,
630 was not present or did not declare
632 so that it was necessary to declare
636 .IR "extern int errno" ).
637 .BR "Do not do this" .
638 It long ago ceased to be necessary,
639 and it will cause problems with modern versions of the C library.
641 .BR errno (1), \" In the moreutils package