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