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