]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/errno.3
accept.2, acct.2, bind.2, clock_getres.2, connect.2, dup.2, epoll_create.2, eventfd...
[thirdparty/man-pages.git] / man3 / errno.3
1 .\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl)
2 .\"
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.
8 .\"
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.
13 .\"
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.
18 .\"
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/>.
22 .\" %%%LICENSE_END
23 .\"
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
30 .\"
31 .TH ERRNO 3 2015-12-28 "" "Linux Programmer's Manual"
32 .SH NAME
33 errno \- number of last error
34 .SH SYNOPSIS
35 .B #include <errno.h>
36 .\".sp
37 .\".BI "extern int " errno ;
38 .SH DESCRIPTION
39 The
40 .I <errno.h>
41 header file defines the integer variable
42 .IR errno ,
43 which is set by system calls and some library functions in the event
44 of an error to indicate what went wrong.
45 Its value is significant only when the return value of
46 the call indicated an error
47 (i.e., \-1 from most system calls;
48 \-1 or NULL from most library functions);
49 a function that succeeds
50 .I is
51 allowed to change
52 .IR errno .
53
54 Valid error numbers are all nonzero;
55 .I errno
56 is never set to zero
57 by any system call or library function.
58
59 For some system calls and library functions (e.g.,
60 .BR getpriority (2)),
61 \-1 is a valid return on success.
62 In such cases, a successful return can be distinguished from an error
63 return by setting
64 .I errno
65 to zero before the call, and then,
66 if the call returns a status that indicates that an error
67 may have occurred, checking to see if
68 .I errno
69 has a nonzero value.
70
71 .I errno
72 is defined by the ISO C standard to be a modifiable lvalue
73 of type
74 .IR int ,
75 and must not be explicitly declared;
76 .I errno
77 may be a macro.
78 .I errno
79 is thread-local; setting it in one thread
80 does not affect its value in any other thread.
81
82 All the error names specified by POSIX.1
83 must have distinct values, with the exception of
84 .B EAGAIN
85 and
86 .BR EWOULDBLOCK ,
87 which may be the same.
88
89 .\" The following is now
90 .\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
91 .\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
92 .\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
93 .\" coding errors in multibyte or wide characters.
94 .\"
95 Below is a list of the symbolic error names that are defined on Linux.
96 Some of these are marked
97 .IR POSIX.1 ,
98 indicating that the name is defined by POSIX.1-2001, or
99 .\" FIXME This list should be updated for POSIX.1-2008
100 .IR C99 ,
101 indicating that the name is defined by C99.
102 .TP 16
103 .B E2BIG
104 Argument list too long (POSIX.1)
105 .TP
106 .B EACCES
107 Permission denied (POSIX.1)
108 .TP
109 .B EADDRINUSE
110 Address already in use (POSIX.1)
111 .TP
112 .B EADDRNOTAVAIL
113 Address not available (POSIX.1)
114 .\" EADV is only an error on HURD(?)
115 .TP
116 .B EAFNOSUPPORT
117 Address family not supported (POSIX.1)
118 .TP
119 .B EAGAIN
120 Resource temporarily unavailable (may be the same value as
121 .BR EWOULDBLOCK )
122 (POSIX.1)
123 .TP
124 .B EALREADY
125 Connection already in progress (POSIX.1)
126 .TP
127 .B EBADE
128 Invalid exchange
129 .TP
130 .B EBADF
131 Bad file descriptor (POSIX.1)
132 .TP
133 .B EBADFD
134 File descriptor in bad state
135 .TP
136 .B EBADMSG
137 Bad message (POSIX.1)
138 .TP
139 .B EBADR
140 Invalid request descriptor
141 .TP
142 .B EBADRQC
143 Invalid request code
144 .TP
145 .B EBADSLT
146 Invalid slot
147 .\" EBFONT is defined but appears not to be used by kernel or glibc.
148 .TP
149 .B EBUSY
150 Device or resource busy (POSIX.1)
151 .TP
152 .B ECANCELED
153 Operation canceled (POSIX.1)
154 .TP
155 .B ECHILD
156 No child processes (POSIX.1)
157 .TP
158 .B ECHRNG
159 Channel number out of range
160 .TP
161 .B ECOMM
162 Communication error on send
163 .TP
164 .B ECONNABORTED
165 Connection aborted (POSIX.1)
166 .TP
167 .B ECONNREFUSED
168 Connection refused (POSIX.1)
169 .TP
170 .B ECONNRESET
171 Connection reset (POSIX.1)
172 .TP
173 .B EDEADLK
174 Resource deadlock avoided (POSIX.1)
175 .TP
176 .B EDEADLOCK
177 Synonym for
178 .B EDEADLK
179 .TP
180 .B EDESTADDRREQ
181 Destination address required (POSIX.1)
182 .TP
183 .B EDOM
184 Mathematics argument out of domain of function (POSIX.1, C99)
185 .\" EDOTDOT is defined but appears to be unused
186 .TP
187 .B EDQUOT
188 .\" POSIX just says "Reserved"
189 Disk quota exceeded (POSIX.1)
190 .TP
191 .B EEXIST
192 File exists (POSIX.1)
193 .TP
194 .B EFAULT
195 Bad address (POSIX.1)
196 .TP
197 .B EFBIG
198 File too large (POSIX.1)
199 .TP
200 .B EHOSTDOWN
201 Host is down
202 .TP
203 .B EHOSTUNREACH
204 Host is unreachable (POSIX.1)
205 .TP
206 .B EIDRM
207 Identifier removed (POSIX.1)
208 .TP
209 .B EILSEQ
210 Illegal byte sequence (POSIX.1, C99)
211 .TP
212 .B EINPROGRESS
213 Operation in progress (POSIX.1)
214 .TP
215 .B EINTR
216 Interrupted function call (POSIX.1); see
217 .BR signal (7).
218 .TP
219 .B EINVAL
220 Invalid argument (POSIX.1)
221 .TP
222 .B EIO
223 Input/output error (POSIX.1)
224 .TP
225 .B EISCONN
226 Socket is connected (POSIX.1)
227 .TP
228 .B EISDIR
229 Is a directory (POSIX.1)
230 .TP
231 .B EISNAM
232 Is a named type file
233 .TP
234 .B EKEYEXPIRED
235 Key has expired
236 .TP
237 .B EKEYREJECTED
238 Key was rejected by service
239 .TP
240 .B EKEYREVOKED
241 Key has been revoked
242 .TP
243 .B EL2HLT
244 Level 2 halted
245 .TP
246 .B EL2NSYNC
247 Level 2 not synchronized
248 .TP
249 .B EL3HLT
250 Level 3 halted
251 .TP
252 .B EL3RST
253 Level 3 halted
254 .TP
255 .B ELIBACC
256 Cannot access a needed shared library
257 .TP
258 .B ELIBBAD
259 Accessing a corrupted shared library
260 .TP
261 .B ELIBMAX
262 Attempting to link in too many shared libraries
263 .TP
264 .B ELIBSCN
265 lib section in a.out corrupted
266 .TP
267 .B ELIBEXEC
268 Cannot exec a shared library directly
269 .TP
270 .B ELOOP
271 Too many levels of symbolic links (POSIX.1)
272 .\" ELNRNG is defined but appears to be unused
273 .TP
274 .B EMEDIUMTYPE
275 Wrong medium type
276 .TP
277 .B EMFILE
278 Too many open files (POSIX.1);
279 commonly caused by exceeding the
280 .BR RLIMIT_NOFILE
281 resource limit described in
282 .BR getrlimit (2)
283 .TP
284 .B EMLINK
285 Too many links (POSIX.1)
286 .TP
287 .B EMSGSIZE
288 Message too long (POSIX.1)
289 .TP
290 .B EMULTIHOP
291 .\" POSIX says "Reserved"
292 Multihop attempted (POSIX.1)
293 .TP
294 .B ENAMETOOLONG
295 Filename too long (POSIX.1)
296 .\" ENAVAIL is defined, but appears not to be used
297 .TP
298 .B ENETDOWN
299 Network is down (POSIX.1)
300 .TP
301 .B ENETRESET
302 Connection aborted by network (POSIX.1)
303 .TP
304 .B ENETUNREACH
305 Network unreachable (POSIX.1)
306 .TP
307 .B ENFILE
308 Too many open files in system (POSIX.1);
309 on Linux, this is probably a result of encountering the
310 .IR /proc/sys/fs/file-max
311 limit (see
312 .BR proc (5)).
313 .\" ENOANO is defined but appears to be unused.
314 .TP
315 .B ENOBUFS
316 No buffer space available (POSIX.1 (XSI STREAMS option))
317 .\" ENOCSI is defined but appears to be unused.
318 .TP
319 .B ENODATA
320 No message is available on the STREAM head read queue (POSIX.1)
321 .TP
322 .B ENODEV
323 No such device (POSIX.1)
324 .TP
325 .B ENOENT
326 No such file or directory (POSIX.1)
327 .TP
328 .B ENOEXEC
329 Exec format error (POSIX.1)
330 .TP
331 .B ENOKEY
332 Required key not available
333 .TP
334 .B ENOLCK
335 No locks available (POSIX.1)
336 .TP
337 .B ENOLINK
338 .\" POSIX says "Reserved"
339 Link has been severed (POSIX.1)
340 .TP
341 .B ENOMEDIUM
342 No medium found
343 .TP
344 .B ENOMEM
345 Not enough space (POSIX.1)
346 .TP
347 .B ENOMSG
348 No message of the desired type (POSIX.1)
349 .TP
350 .B ENONET
351 Machine is not on the network
352 .TP
353 .B ENOPKG
354 Package not installed
355 .TP
356 .B ENOPROTOOPT
357 Protocol not available (POSIX.1)
358 .TP
359 .B ENOSPC
360 No space left on device (POSIX.1)
361 .TP
362 .B ENOSR
363 No STREAM resources (POSIX.1 (XSI STREAMS option))
364 .TP
365 .B ENOSTR
366 Not a STREAM (POSIX.1 (XSI STREAMS option))
367 .TP
368 .B ENOSYS
369 Function not implemented (POSIX.1)
370 .TP
371 .B ENOTBLK
372 Block device required
373 .TP
374 .B ENOTCONN
375 The socket is not connected (POSIX.1)
376 .TP
377 .B ENOTDIR
378 Not a directory (POSIX.1)
379 .TP
380 .B ENOTEMPTY
381 Directory not empty (POSIX.1)
382 .\" ENOTNAM is defined but appears to be unused.
383 .TP
384 .B ENOTSOCK
385 Not a socket (POSIX.1)
386 .TP
387 .B ENOTSUP
388 Operation not supported (POSIX.1)
389 .TP
390 .B ENOTTY
391 Inappropriate I/O control operation (POSIX.1)
392 .TP
393 .B ENOTUNIQ
394 Name not unique on network
395 .TP
396 .B ENXIO
397 No such device or address (POSIX.1)
398 .TP
399 .B EOPNOTSUPP
400 Operation not supported on socket (POSIX.1)
401 .sp
402 .RB ( ENOTSUP
403 and
404 .B EOPNOTSUPP
405 have the same value on Linux, but
406 according to POSIX.1 these error values should be distinct.)
407 .TP
408 .B EOVERFLOW
409 Value too large to be stored in data type (POSIX.1)
410 .TP
411 .B EPERM
412 Operation not permitted (POSIX.1)
413 .TP
414 .B EPFNOSUPPORT
415 Protocol family not supported
416 .TP
417 .B EPIPE
418 Broken pipe (POSIX.1)
419 .TP
420 .B EPROTO
421 Protocol error (POSIX.1)
422 .TP
423 .B EPROTONOSUPPORT
424 Protocol not supported (POSIX.1)
425 .TP
426 .B EPROTOTYPE
427 Protocol wrong type for socket (POSIX.1)
428 .TP
429 .B ERANGE
430 Result too large (POSIX.1, C99)
431 .TP
432 .B EREMCHG
433 Remote address changed
434 .TP
435 .B EREMOTE
436 Object is remote
437 .TP
438 .B EREMOTEIO
439 Remote I/O error
440 .TP
441 .B ERESTART
442 Interrupted system call should be restarted
443 .TP
444 .B EROFS
445 Read-only filesystem (POSIX.1)
446 .TP
447 .B ESHUTDOWN
448 Cannot send after transport endpoint shutdown
449 .TP
450 .B ESPIPE
451 Invalid seek (POSIX.1)
452 .TP
453 .B ESOCKTNOSUPPORT
454 Socket type not supported
455 .TP
456 .B ESRCH
457 No such process (POSIX.1)
458 .\" ESRMNT is defined but appears not to be used
459 .TP
460 .B ESTALE
461 Stale file handle (POSIX.1)
462 .sp
463 This error can occur for NFS and for other filesystems
464 .TP
465 .B ESTRPIPE
466 Streams pipe error
467 .TP
468 .B ETIME
469 Timer expired
470 (POSIX.1 (XSI STREAMS option))
471 .sp
472 (POSIX.1 says "STREAM
473 .BR ioctl (2)
474 timeout")
475 .TP
476 .B ETIMEDOUT
477 Connection timed out (POSIX.1)
478 .\" ETOOMANYREFS is defined, but appears not to be used.
479 .TP
480 .B ETXTBSY
481 Text file busy (POSIX.1)
482 .TP
483 .B EUCLEAN
484 Structure needs cleaning
485 .TP
486 .B EUNATCH
487 Protocol driver not attached
488 .TP
489 .B EUSERS
490 Too many users
491 .TP
492 .B EWOULDBLOCK
493 Operation would block (may be same value as
494 .BR EAGAIN )
495 (POSIX.1)
496 .TP
497 .B EXDEV
498 Improper link (POSIX.1)
499 .TP
500 .B EXFULL
501 Exchange full
502 .SH NOTES
503 A common mistake is to do
504 .in +4n
505 .nf
506
507 if (somecall() == \-1) {
508 printf("somecall() failed\en");
509 if (errno == ...) { ... }
510 }
511
512 .fi
513 .in
514 where
515 .I errno
516 no longer needs to have the value it had upon return from
517 .IR somecall ()
518 (i.e., it may have been changed by the
519 .BR printf (3)).
520 If the value of
521 .I errno
522 should be preserved across a library call, it must be saved:
523 .in +4n
524 .nf
525
526 if (somecall() == \-1) {
527 int errsv = errno;
528 printf("somecall() failed\en");
529 if (errsv == ...) { ... }
530 }
531 .fi
532 .in
533 .PP
534 It was common in traditional C to declare
535 .I errno
536 manually
537 (i.e.,
538 .IR "extern int errno" )
539 instead of including
540 .IR <errno.h> .
541 .BR "Do not do this" .
542 It will not work with modern versions of the C library.
543 However, on (very) old UNIX systems, there may be no
544 .I <errno.h>
545 and the declaration is needed.
546 .SH SEE ALSO
547 .BR errno (1), \" In the moreutils package
548 .BR err (3),
549 .BR error (3),
550 .BR perror (3),
551 .BR strerror (3)