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-03-06 "" "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
122 EPERM 1 Operation not permitted
123 ENOENT 2 No such file or directory
124 ESRCH 3 No such process
125 EINTR 4 Interrupted system call
126 EIO 5 Input/output error
133 command can also be used to look up individual error numbers and names,
134 and to search for errors using strings from the error description,
135 as in the following examples:
140 ENOENT 2 No such file or directory
142 ESRCH 3 No such process
143 $ \fBerrno \-s permission\fP
144 EACCES 13 Permission denied
148 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
149 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
150 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
151 .\" coding errors in multibyte or wide characters.
153 .SS List of error names
154 In the list of the symbolic error names below,
155 various names are marked as follows:
158 The name is defined by POSIX.1-2001,
159 and is defined in later POSIX.1 versions, unless otherwise indicated.
162 The name is defined in POSIX.1-2008,
163 but was not present in earlier POSIX.1 standards.
166 The name is defined by C99.
167 Below is a list of the symbolic error names that are defined on Linux:
170 Argument list too long (POSIX.1-2001).
173 Permission denied (POSIX.1-2001).
176 Address already in use (POSIX.1-2001).
179 Address not available (POSIX.1-2001).
180 .\" EADV is only an error on HURD(?)
183 Address family not supported (POSIX.1-2001).
186 Resource temporarily unavailable (may be the same value as
191 Connection already in progress (POSIX.1-2001).
197 Bad file descriptor (POSIX.1-2001).
200 File descriptor in bad state.
203 Bad message (POSIX.1-2001).
206 Invalid request descriptor.
209 Invalid request code.
213 .\" EBFONT is defined but appears not to be used by kernel or glibc.
216 Device or resource busy (POSIX.1-2001).
219 Operation canceled (POSIX.1-2001).
222 No child processes (POSIX.1-2001).
225 Channel number out of range.
228 Communication error on send.
231 Connection aborted (POSIX.1-2001).
234 Connection refused (POSIX.1-2001).
237 Connection reset (POSIX.1-2001).
240 Resource deadlock avoided (POSIX.1-2001).
247 Destination address required (POSIX.1-2001).
250 Mathematics argument out of domain of function (POSIX.1, C99).
251 .\" EDOTDOT is defined but appears to be unused
254 .\" POSIX just says "Reserved"
255 Disk quota exceeded (POSIX.1-2001).
258 File exists (POSIX.1-2001).
261 Bad address (POSIX.1-2001).
264 File too large (POSIX.1-2001).
270 Host is unreachable (POSIX.1-2001).
273 Memory page has hardware error.
276 Identifier removed (POSIX.1-2001).
279 Invalid or incomplete multibyte or wide character (POSIX.1, C99).
281 The text shown here is the glibc error description;
282 in POSIX.1, this error is described as "Illegal byte sequence".
285 Operation in progress (POSIX.1-2001).
288 Interrupted function call (POSIX.1-2001); see
292 Invalid argument (POSIX.1-2001).
295 Input/output error (POSIX.1-2001).
298 Socket is connected (POSIX.1-2001).
301 Is a directory (POSIX.1-2001).
304 Is a named type file.
310 Key was rejected by service.
313 Key has been revoked.
319 Level 2 not synchronized.
328 Cannot access a needed shared library.
331 Accessing a corrupted shared library.
334 Attempting to link in too many shared libraries.
337 \&.lib section in a.out corrupted
340 Cannot exec a shared library directly.
343 .\" ELNRNG appears to be used by a few drivers
344 Link number out of range.
347 Too many levels of symbolic links (POSIX.1-2001).
353 Too many open files (POSIX.1-2001).
354 Commonly caused by exceeding the
356 resource limit described in
360 Too many links (POSIX.1-2001).
363 Message too long (POSIX.1-2001).
366 .\" POSIX says "Reserved"
367 Multihop attempted (POSIX.1-2001).
370 Filename too long (POSIX.1-2001).
371 .\" ENAVAIL is defined, but appears not to be used
374 Network is down (POSIX.1-2001).
377 Connection aborted by network (POSIX.1-2001).
380 Network unreachable (POSIX.1-2001).
383 Too many open files in system (POSIX.1-2001).
384 On Linux, this is probably a result of encountering the
385 .IR /proc/sys/fs/file-max
390 .\" ENOANO appears to be used by a few drivers
394 No buffer space available (POSIX.1 (XSI STREAMS option)).
395 .\" ENOCSI is defined but appears to be unused.
398 No message is available on the STREAM head read queue (POSIX.1-2001).
401 No such device (POSIX.1-2001).
404 No such file or directory (POSIX.1-2001).
406 Typically, this error results when a specified pathname does not exist,
407 or one of the components in the directory prefix of a pathname does not exist,
408 or the specified pathname is a dangling symbolic link.
411 Exec format error (POSIX.1-2001).
414 Required key not available.
417 No locks available (POSIX.1-2001).
420 .\" POSIX says "Reserved"
421 Link has been severed (POSIX.1-2001).
427 Not enough space/cannot allocate memory (POSIX.1-2001).
430 No message of the desired type (POSIX.1-2001).
433 Machine is not on the network.
436 Package not installed.
439 Protocol not available (POSIX.1-2001).
442 No space left on device (POSIX.1-2001).
445 No STREAM resources (POSIX.1 (XSI STREAMS option)).
448 Not a STREAM (POSIX.1 (XSI STREAMS option)).
451 Function not implemented (POSIX.1-2001).
454 Block device required.
457 The socket is not connected (POSIX.1-2001).
460 Not a directory (POSIX.1-2001).
463 Directory not empty (POSIX.1-2001).
464 .\" ENOTNAM is defined but appears to be unused.
467 State not recoverable (POSIX.1-2008).
470 Not a socket (POSIX.1-2001).
473 Operation not supported (POSIX.1-2001).
476 Inappropriate I/O control operation (POSIX.1-2001).
479 Name not unique on network.
482 No such device or address (POSIX.1-2001).
485 Operation not supported on socket (POSIX.1-2001).
490 have the same value on Linux, but
491 according to POSIX.1 these error values should be distinct.)
494 Value too large to be stored in data type (POSIX.1-2001).
497 .\" Used at least by the user-space side of rubost mutexes
498 Owner died (POSIX.1-2008).
501 Operation not permitted (POSIX.1-2001).
504 Protocol family not supported.
507 Broken pipe (POSIX.1-2001).
510 Protocol error (POSIX.1-2001).
513 Protocol not supported (POSIX.1-2001).
516 Protocol wrong type for socket (POSIX.1-2001).
519 Result too large (POSIX.1, C99).
522 Remote address changed.
531 Interrupted system call should be restarted.
534 .\" ERFKILL appears to be used by various drivers
535 Operation not possible due to RF-kill.
538 Read-only filesystem (POSIX.1-2001).
541 Cannot send after transport endpoint shutdown.
544 Invalid seek (POSIX.1-2001).
547 Socket type not supported.
550 No such process (POSIX.1-2001).
551 .\" ESRMNT is defined but appears not to be used
554 Stale file handle (POSIX.1-2001).
556 This error can occur for NFS and for other filesystems.
563 (POSIX.1 (XSI STREAMS option)).
565 (POSIX.1 says "STREAM
570 Connection timed out (POSIX.1-2001).
573 .\" ETOOMANYREFS seems to be used in net/unix/af_unix.c
574 Too many references: cannot splice.
577 Text file busy (POSIX.1-2001).
580 Structure needs cleaning.
583 Protocol driver not attached.
589 Operation would block (may be same value as
594 Improper link (POSIX.1-2001).
599 A common mistake is to do
603 if (somecall() == \-1) {
604 printf("somecall() failed\en");
605 if (errno == ...) { ... }
612 no longer needs to have the value it had upon return from
614 (i.e., it may have been changed by the
618 should be preserved across a library call, it must be saved:
622 if (somecall() == \-1) {
624 printf("somecall() failed\en");
625 if (errsv == ...) { ... }
630 On some ancient systems,
632 was not present or did not declare
634 so that it was necessary to declare
638 .IR "extern int errno" ).
639 .BR "Do not do this" .
640 It long ago ceased to be necessary,
641 and it will cause problems with modern versions of the C library.
643 .BR errno (1), \" In the moreutils package