1 .\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl)
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.
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.
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.
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,
23 .\" 5 Oct 2002, Modified by Michael Kerrisk <mtk-manpages@gmx.net>
24 .\" Updated for POSIX 1003.1 2001
25 .\" 2004-12-17 Martin Schulze <joey@infodrom.org>, mtk
26 .\" Removed errno declaration prototype, added notes
28 .TH ERRNO 3 2004-12-17 "" "Library functions"
30 errno \- number of last error
34 .\".BI "extern int " errno ;
38 header file defines the integer variable
40 which is set by system calls and some library functions in the event
41 of an error to indicate what went wrong.
42 Its value is significant only when the call
43 returned an error (usually \-1), and a function that does succeed
47 Sometimes, when \-1 is also a valid successful return value
50 before the call in order to detect possible errors.
52 \fBerrno\fR is defined by the ISO C standard to be a modifiable lvalue
53 of type \fBint\fR, and must not be explicitly declared; \fBerrno\fR
54 may be a macro. \fBerrno\fR is thread-local; setting it in one thread
55 does not affect its value in any other thread.
57 Valid error numbers are all non-zero; \fBerrno\fR is never set to zero
58 by any library function. All the error names specified by POSIX.1
59 must have distinct values, with the exception of
63 which may be the same.
65 .\" FIXME EILSEQ is in C99.
66 POSIX.1 (2001 edition) lists the following symbolic error names. Of
67 these, \fBEDOM\fR and \fBERANGE\fR are in the ISO C standard. ISO C
68 Amendment 1 defines the additional error number \fBEILSEQ\fR for
69 coding errors in multibyte or wide characters.
71 .\" FIXME The following list is far from complete
86 Address family not supported
89 Resource temporarily unavailable
92 Connection already in progress
119 Resource deadlock avoided
122 Destination address required
146 Illegal byte sequence
149 Operation in progress
152 Interrupted function call
167 Too many levels of symbolic links
176 Inappropriate message buffer length
188 Connection aborted by network
194 Too many open files in system
197 No buffer space available
198 .\" ENODATA is part of XSR option
201 No message is available on the STREAM head read queue
207 No such file or directory
222 No message of the desired type
225 Protocol not available
228 No space left on device
229 .\" ENOSR is part of XSR option
233 .\" ENOSTR is part of XSR option
239 Function not implemented
242 The socket is not connected
257 Inappropriate I/O control operation
260 No such device or address
263 Operation not supported on socket
266 Value too large to be stored in data type
269 Operation not permitted
278 Protocol not supported
281 Protocol wrong type for socket
287 Read-only file system
297 .\" Can occur for NFS and for other file systems
298 .\" ETIME is part of XSR option
312 Operation would block (may be same value as
318 A common mistake is to do
322 if (somecall() == \-1) {
323 printf("somecall() failed\en");
324 if (errno == ...) { ... }
331 no longer needs to have the value it had upon return from
333 (i.e., it may have been changed by the
337 should be preserved across a library call, it must be saved:
341 if (somecall() == \-1) {
343 printf("somecall() failed\en");
344 if (errsv == ...) { ... }
349 It was common in traditional C to declare
353 .IR "extern int errno" )
356 .BR "Do not do this" .
357 It will not work with modern versions of the C library.
358 However, on (very) old Unix systems, there may be no
360 and the declaration is needed.