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.
47 is never set to zero by any system call or library function.
50 is significant only when the return value of
51 the call indicated an error
52 (i.e., \-1 from most system calls;
53 \-1 or NULL from most library functions);
54 a function that succeeds
59 Valid error numbers are all nonzero.
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 All the error names specified by POSIX.1
85 must have distinct values, with the exception of
89 which may be the same.
91 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
92 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
93 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
94 .\" coding errors in multibyte or wide characters.
96 In the list of the symbolic error names below,
97 various names are marked as follows:
101 The name is defined by POSIX.1-2001,
102 and is defined in later POSIX.1 versions, unless otherwise indicated.
105 The name is defined in POSIX.1-2008,
106 but was not present in earlier POSIX.1 standards.
109 The name is defined by C99.
112 Below is a list of the symbolic error names that are defined on Linux:
115 Argument list too long (POSIX.1-2001).
118 Permission denied (POSIX.1-2001).
121 Address already in use (POSIX.1-2001).
124 Address not available (POSIX.1-2001).
125 .\" EADV is only an error on HURD(?)
128 Address family not supported (POSIX.1-2001).
131 Resource temporarily unavailable (may be the same value as
136 Connection already in progress (POSIX.1-2001).
142 Bad file descriptor (POSIX.1-2001).
145 File descriptor in bad state.
148 Bad message (POSIX.1-2001).
151 Invalid request descriptor.
154 Invalid request code.
158 .\" EBFONT is defined but appears not to be used by kernel or glibc.
161 Device or resource busy (POSIX.1-2001).
164 Operation canceled (POSIX.1-2001).
167 No child processes (POSIX.1-2001).
170 Channel number out of range.
173 Communication error on send.
176 Connection aborted (POSIX.1-2001).
179 Connection refused (POSIX.1-2001).
182 Connection reset (POSIX.1-2001).
185 Resource deadlock avoided (POSIX.1-2001).
192 Destination address required (POSIX.1-2001).
195 Mathematics argument out of domain of function (POSIX.1, C99).
196 .\" EDOTDOT is defined but appears to be unused
199 .\" POSIX just says "Reserved"
200 Disk quota exceeded (POSIX.1-2001).
203 File exists (POSIX.1-2001).
206 Bad address (POSIX.1-2001).
209 File too large (POSIX.1-2001).
215 Host is unreachable (POSIX.1-2001).
218 Memory page has hardware error.
221 Identifier removed (POSIX.1-2001).
224 Invalid or incomplete multibyte or wide character (POSIX.1, C99).
226 The text shown here is the glibc error description;
227 in POSIX.1, this error is described as "Illegal byte sequence".
230 Operation in progress (POSIX.1-2001).
233 Interrupted function call (POSIX.1-2001); see
237 Invalid argument (POSIX.1-2001).
240 Input/output error (POSIX.1-2001).
243 Socket is connected (POSIX.1-2001).
246 Is a directory (POSIX.1-2001).
249 Is a named type file.
255 Key was rejected by service.
258 Key has been revoked.
264 Level 2 not synchronized.
273 Cannot access a needed shared library.
276 Accessing a corrupted shared library.
279 Attempting to link in too many shared libraries.
282 \&.lib section in a.out corrupted
285 Cannot exec a shared library directly.
288 .\" ELNRNG appears to be used by a few drivers
289 Link number out of range.
292 Too many levels of symbolic links (POSIX.1-2001).
298 Too many open files (POSIX.1-2001).
299 Commonly caused by exceeding the
301 resource limit described in
305 Too many links (POSIX.1-2001).
308 Message too long (POSIX.1-2001).
311 .\" POSIX says "Reserved"
312 Multihop attempted (POSIX.1-2001).
315 Filename too long (POSIX.1-2001).
316 .\" ENAVAIL is defined, but appears not to be used
319 Network is down (POSIX.1-2001).
322 Connection aborted by network (POSIX.1-2001).
325 Network unreachable (POSIX.1-2001).
328 Too many open files in system (POSIX.1-2001).
329 On Linux, this is probably a result of encountering the
330 .IR /proc/sys/fs/file-max
335 .\" ENOANO appears to be used by a few drivers
339 No buffer space available (POSIX.1 (XSI STREAMS option)).
340 .\" ENOCSI is defined but appears to be unused.
343 No message is available on the STREAM head read queue (POSIX.1-2001).
346 No such device (POSIX.1-2001).
349 No such file or directory (POSIX.1-2001).
351 Typically, this error results when a specified pathname does not exist,
352 or one of the components in the directory prefix of a pathname does not exist,
353 or the specified pathname is a dangling symbolic link.
356 Exec format error (POSIX.1-2001).
359 Required key not available.
362 No locks available (POSIX.1-2001).
365 .\" POSIX says "Reserved"
366 Link has been severed (POSIX.1-2001).
372 Not enough space (POSIX.1-2001).
375 No message of the desired type (POSIX.1-2001).
378 Machine is not on the network.
381 Package not installed.
384 Protocol not available (POSIX.1-2001).
387 No space left on device (POSIX.1-2001).
390 No STREAM resources (POSIX.1 (XSI STREAMS option)).
393 Not a STREAM (POSIX.1 (XSI STREAMS option)).
396 Function not implemented (POSIX.1-2001).
399 Block device required.
402 The socket is not connected (POSIX.1-2001).
405 Not a directory (POSIX.1-2001).
408 Directory not empty (POSIX.1-2001).
409 .\" ENOTNAM is defined but appears to be unused.
412 State not recoverable (POSIX.1-2008).
415 Not a socket (POSIX.1-2001).
418 Operation not supported (POSIX.1-2001).
421 Inappropriate I/O control operation (POSIX.1-2001).
424 Name not unique on network.
427 No such device or address (POSIX.1-2001).
430 Operation not supported on socket (POSIX.1-2001).
435 have the same value on Linux, but
436 according to POSIX.1 these error values should be distinct.)
439 Value too large to be stored in data type (POSIX.1-2001).
442 .\" Used at least by the user-space side of rubost mutexes
443 Owner died (POSIX.1-2008).
446 Operation not permitted (POSIX.1-2001).
449 Protocol family not supported.
452 Broken pipe (POSIX.1-2001).
455 Protocol error (POSIX.1-2001).
458 Protocol not supported (POSIX.1-2001).
461 Protocol wrong type for socket (POSIX.1-2001).
464 Result too large (POSIX.1, C99).
467 Remote address changed.
476 Interrupted system call should be restarted.
479 .\" ERFKILL appears to be used by various drivers
480 Operation not possible due to RF-kill.
483 Read-only filesystem (POSIX.1-2001).
486 Cannot send after transport endpoint shutdown.
489 Invalid seek (POSIX.1-2001).
492 Socket type not supported.
495 No such process (POSIX.1-2001).
496 .\" ESRMNT is defined but appears not to be used
499 Stale file handle (POSIX.1-2001).
501 This error can occur for NFS and for other filesystems.
508 (POSIX.1 (XSI STREAMS option))
510 (POSIX.1 says "STREAM
515 Connection timed out (POSIX.1-2001).
518 .\" ETOOMANYREFS seems to be used in net/unix/af_unix.c
519 Too many references: cannot splice.
522 Text file busy (POSIX.1-2001).
525 Structure needs cleaning.
528 Protocol driver not attached.
534 Operation would block (may be same value as
539 Improper link (POSIX.1-2001).
544 A common mistake is to do
548 if (somecall() == \-1) {
549 printf("somecall() failed\en");
550 if (errno == ...) { ... }
557 no longer needs to have the value it had upon return from
559 (i.e., it may have been changed by the
563 should be preserved across a library call, it must be saved:
567 if (somecall() == \-1) {
569 printf("somecall() failed\en");
570 if (errsv == ...) { ... }
575 It was common in traditional C to declare
579 .IR "extern int errno" )
582 .BR "Do not do this" .
583 It will not work with modern versions of the C library.
584 However, on (very) old UNIX systems, there may be no
586 and the declaration is needed.
588 .BR errno (1), \" In the moreutils package