]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/errno.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[thirdparty/man-pages.git] / man3 / errno.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl)
2.\"
1dd72f9c 3.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
fea681da
MK
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
c715f741
MK
20.\" License along with this manual; if not, see
21.\" <http://www.gnu.org/licenses/>.
6a8d8745 22.\" %%%LICENSE_END
fea681da 23.\"
c11b1abf 24.\" 5 Oct 2002, Modified by Michael Kerrisk <mtk.manpages@gmail.com>
68e1685c 25.\" Updated for POSIX.1 2001
05432883
MK
26.\" 2004-12-17 Martin Schulze <joey@infodrom.org>, mtk
27.\" Removed errno declaration prototype, added notes
a0ddea87
MK
28.\" 2006-02-09 Kurt Wall, mtk
29.\" Added non-POSIX errors
fea681da 30.\"
8538a62b 31.TH ERRNO 3 2018-02-02 "" "Linux Programmer's Manual"
fea681da
MK
32.SH NAME
33errno \- number of last error
34.SH SYNOPSIS
35.B #include <errno.h>
68e4db0a 36.\".PP
05432883 37.\".BI "extern int " errno ;
fea681da 38.SH DESCRIPTION
c13182ef 39The
05432883
MK
40.I <errno.h>
41header file defines the integer variable
09b235db 42.IR errno ,
05432883
MK
43which is set by system calls and some library functions in the event
44of an error to indicate what went wrong.
b89ec852
MK
45.\"
46.SS errno
a9641f84
MK
47The value in
48.I errno
49is significant only when the return value of
929ccaa3
MK
50the call indicated an error
51(i.e., \-1 from most system calls;
52\-1 or NULL from most library functions);
53a function that succeeds
54.I is
55allowed to change
09b235db 56.IR errno .
b89ec852
MK
57The value of
58.I errno
59is never set to zero by any system call or library function.
847e0d88 60.PP
929ccaa3
MK
61For some system calls and library functions (e.g.,
62.BR getpriority (2)),
63\-1 is a valid return on success.
64In such cases, a successful return can be distinguished from an error
65return by setting
09b235db 66.I errno
929ccaa3
MK
67to zero before the call, and then,
68if the call returns a status that indicates that an error
69may have occurred, checking to see if
70.I errno
c7094399 71has a nonzero value.
847e0d88 72.PP
c6fa0841
MK
73.I errno
74is defined by the ISO C standard to be a modifiable lvalue
75of type
76.IR int ,
77and must not be explicitly declared;
78.I errno
be7fff26 79may be a macro.
c6fa0841
MK
80.I errno
81is thread-local; setting it in one thread
fea681da 82does not affect its value in any other thread.
b89ec852
MK
83.\"
84.SS Error numbers and names
9d1a5fa6 85Valid error numbers are all positive numbers.
b89ec852
MK
86The
87.I <errno.h>
88header file defines symbolic names for each
89of the possible error numbers that may appear in
90.IR errno .
847e0d88 91.PP
c13182ef 92All the error names specified by POSIX.1
05432883
MK
93must have distinct values, with the exception of
94.B EAGAIN
c13182ef 95and
05432883
MK
96.BR EWOULDBLOCK ,
97which may be the same.
847e0d88 98.PP
f7921478
MK
99The error numbers that correspond to each symbolic name
100vary across UNIX systems,
101and even across different architectures on Linux.
b01ecc5e 102Therefore, numeric values are not included as part of the list of
bf3683a1 103error names below.
5a99c722
MK
104The
105.BR perror (3)
106and
107.BR strerror (3)
108functions can be used to convert these names to
109corresponding textual error messages.
afde18c0
MK
110.PP
111On any particular Linux system,
44a35dc8
MK
112one can obtain a list of all symbolic error names and
113the corresponding error numbers using the
114.BR errno (1)
385a5b3d
MK
115command (part of the
116.I moreutils
117package):
44a35dc8
MK
118.PP
119.in +4n
120.EX
121$ \fBerrno \-l\fP
122EPERM 1 Operation not permitted
123ENOENT 2 No such file or directory
124ESRCH 3 No such process
125EINTR 4 Interrupted system call
126EIO 5 Input/output error
127\&...
128.EE
129.in
130.PP
131The
132.BR errno (1)
d2cd4588
MK
133command can also be used to look up individual error numbers and names,
134and to search for errors using strings from the error description,
44a35dc8
MK
135as in the following examples:
136.PP
137.in +4n
138.EX
139$ \fBerrno 2\fP
140ENOENT 2 No such file or directory
141$ \fBerrno ESRCH\fP
142ESRCH 3 No such process
d2cd4588
MK
143$ \fBerrno \-s permission\fP
144EACCES 13 Permission denied
44a35dc8
MK
145.EE
146.in
bf3683a1 147.PP
a0ddea87 148.\" POSIX.1 (2001 edition) lists the following symbolic error names. Of
a8d55537
MK
149.\" these, \fBEDOM\fP and \fBERANGE\fP are in the ISO C standard. ISO C
150.\" Amendment 1 defines the additional error number \fBEILSEQ\fP for
a0ddea87 151.\" coding errors in multibyte or wide characters.
c13182ef 152.\"
b89ec852 153.SS List of error names
e4a5b662
MK
154In the list of the symbolic error names below,
155various names are marked as follows:
5a63455f
MK
156.IP * 3
157.IR POSIX.1-2001 :
158The name is defined by POSIX.1-2001,
159and is defined in later POSIX.1 versions, unless otherwise indicated.
160.IP *
161.IR POSIX.1-2008 :
162The name is defined in POSIX.1-2008,
163but was not present in earlier POSIX.1 standards.
164.IP *
165.IR C99 :
166The name is defined by C99.
e4a5b662 167Below is a list of the symbolic error names that are defined on Linux:
dbb8ac51 168.TP 16
0daa9e92 169.B E2BIG
5a63455f 170Argument list too long (POSIX.1-2001).
fea681da 171.TP
0daa9e92 172.B EACCES
5a63455f 173Permission denied (POSIX.1-2001).
fea681da 174.TP
0daa9e92 175.B EADDRINUSE
5a63455f 176Address already in use (POSIX.1-2001).
fea681da 177.TP
0daa9e92 178.B EADDRNOTAVAIL
5a63455f 179Address not available (POSIX.1-2001).
a0ddea87 180.\" EADV is only an error on HURD(?)
fea681da 181.TP
0daa9e92 182.B EAFNOSUPPORT
5a63455f 183Address family not supported (POSIX.1-2001).
fea681da 184.TP
0daa9e92 185.B EAGAIN
c13182ef 186Resource temporarily unavailable (may be the same value as
a0ddea87 187.BR EWOULDBLOCK )
5a63455f 188(POSIX.1-2001).
a0ddea87 189.TP
0daa9e92 190.B EALREADY
5a63455f 191Connection already in progress (POSIX.1-2001).
a0ddea87 192.TP
0daa9e92 193.B EBADE
31071798 194Invalid exchange.
a0ddea87 195.TP
0daa9e92 196.B EBADF
5a63455f 197Bad file descriptor (POSIX.1-2001).
a0ddea87 198.TP
0daa9e92 199.B EBADFD
31071798 200File descriptor in bad state.
fea681da 201.TP
0daa9e92 202.B EBADMSG
5a63455f 203Bad message (POSIX.1-2001).
fea681da 204.TP
0daa9e92 205.B EBADR
31071798 206Invalid request descriptor.
fea681da 207.TP
0daa9e92 208.B EBADRQC
31071798 209Invalid request code.
fea681da 210.TP
0daa9e92 211.B EBADSLT
31071798 212Invalid slot.
a0ddea87 213.\" EBFONT is defined but appears not to be used by kernel or glibc.
fea681da 214.TP
0daa9e92 215.B EBUSY
5a63455f 216Device or resource busy (POSIX.1-2001).
fea681da 217.TP
0daa9e92 218.B ECANCELED
5a63455f 219Operation canceled (POSIX.1-2001).
fea681da 220.TP
0daa9e92 221.B ECHILD
5a63455f 222No child processes (POSIX.1-2001).
fea681da 223.TP
a0ddea87 224.B ECHRNG
31071798 225Channel number out of range.
fea681da 226.TP
a0ddea87 227.B ECOMM
31071798 228Communication error on send.
fea681da 229.TP
0daa9e92 230.B ECONNABORTED
5a63455f 231Connection aborted (POSIX.1-2001).
a0ddea87 232.TP
0daa9e92 233.B ECONNREFUSED
5a63455f 234Connection refused (POSIX.1-2001).
a0ddea87 235.TP
0daa9e92 236.B ECONNRESET
5a63455f 237Connection reset (POSIX.1-2001).
a0ddea87 238.TP
0daa9e92 239.B EDEADLK
5a63455f 240Resource deadlock avoided (POSIX.1-2001).
a0ddea87 241.TP
0daa9e92 242.B EDEADLOCK
a0ddea87 243Synonym for
31071798 244.BR EDEADLK .
fea681da 245.TP
0daa9e92 246.B EDESTADDRREQ
5a63455f 247Destination address required (POSIX.1-2001).
a0ddea87 248.TP
0daa9e92 249.B EDOM
31071798 250Mathematics argument out of domain of function (POSIX.1, C99).
a0ddea87
MK
251.\" EDOTDOT is defined but appears to be unused
252.TP
0daa9e92 253.B EDQUOT
a0ddea87 254.\" POSIX just says "Reserved"
5a63455f 255Disk quota exceeded (POSIX.1-2001).
a0ddea87 256.TP
0daa9e92 257.B EEXIST
5a63455f 258File exists (POSIX.1-2001).
a0ddea87 259.TP
0daa9e92 260.B EFAULT
5a63455f 261Bad address (POSIX.1-2001).
a0ddea87 262.TP
0daa9e92 263.B EFBIG
5a63455f 264File too large (POSIX.1-2001).
a0ddea87 265.TP
0daa9e92 266.B EHOSTDOWN
31071798 267Host is down.
a0ddea87 268.TP
0daa9e92 269.B EHOSTUNREACH
5a63455f 270Host is unreachable (POSIX.1-2001).
a0ddea87 271.TP
975c0f87
MK
272.B EHWPOISON
273Memory page has hardware error.
274.TP
0daa9e92 275.B EIDRM
5a63455f 276Identifier removed (POSIX.1-2001).
a0ddea87 277.TP
0daa9e92 278.B EILSEQ
d411041b 279Invalid or incomplete multibyte or wide character (POSIX.1, C99).
847e0d88 280.IP
d411041b
MK
281The text shown here is the glibc error description;
282in POSIX.1, this error is described as "Illegal byte sequence".
a0ddea87 283.TP
0daa9e92 284.B EINPROGRESS
5a63455f 285Operation in progress (POSIX.1-2001).
a0ddea87 286.TP
0daa9e92 287.B EINTR
5a63455f 288Interrupted function call (POSIX.1-2001); see
0b6d88cf 289.BR signal (7).
a0ddea87 290.TP
0daa9e92 291.B EINVAL
5a63455f 292Invalid argument (POSIX.1-2001).
fea681da 293.TP
0daa9e92 294.B EIO
5a63455f 295Input/output error (POSIX.1-2001).
fea681da 296.TP
0daa9e92 297.B EISCONN
5a63455f 298Socket is connected (POSIX.1-2001).
fea681da 299.TP
0daa9e92 300.B EISDIR
5a63455f 301Is a directory (POSIX.1-2001).
fea681da 302.TP
0daa9e92 303.B EISNAM
31071798 304Is a named type file.
fea681da 305.TP
0daa9e92 306.B EKEYEXPIRED
31071798 307Key has expired.
fea681da 308.TP
0daa9e92 309.B EKEYREJECTED
31071798 310Key was rejected by service.
fea681da 311.TP
0daa9e92 312.B EKEYREVOKED
31071798 313Key has been revoked.
fea681da 314.TP
a0ddea87 315.B EL2HLT
31071798 316Level 2 halted.
fea681da 317.TP
a0ddea87 318.B EL2NSYNC
31071798 319Level 2 not synchronized.
fea681da 320.TP
a0ddea87 321.B EL3HLT
31071798 322Level 3 halted.
fea681da 323.TP
a0ddea87 324.B EL3RST
14ecabec 325Level 3 reset.
fea681da 326.TP
0daa9e92 327.B ELIBACC
31071798 328Cannot access a needed shared library.
fea681da 329.TP
0daa9e92 330.B ELIBBAD
31071798 331Accessing a corrupted shared library.
fea681da 332.TP
0daa9e92 333.B ELIBMAX
31071798 334Attempting to link in too many shared libraries.
fea681da 335.TP
0daa9e92 336.B ELIBSCN
e1f3482c 337\&.lib section in a.out corrupted
fea681da 338.TP
0daa9e92 339.B ELIBEXEC
31071798 340Cannot exec a shared library directly.
fea681da 341.TP
975c0f87
MK
342.B ELNRANGE
343.\" ELNRNG appears to be used by a few drivers
344Link number out of range.
345.TP
0daa9e92 346.B ELOOP
5a63455f 347Too many levels of symbolic links (POSIX.1-2001).
fea681da 348.TP
0daa9e92 349.B EMEDIUMTYPE
31071798 350Wrong medium type.
fea681da 351.TP
0daa9e92 352.B EMFILE
5a63455f 353Too many open files (POSIX.1-2001).
31071798 354Commonly caused by exceeding the
0c38aa2c
MK
355.BR RLIMIT_NOFILE
356resource limit described in
31071798 357.BR getrlimit (2).
fea681da 358.TP
0daa9e92 359.B EMLINK
5a63455f 360Too many links (POSIX.1-2001).
fea681da 361.TP
0daa9e92 362.B EMSGSIZE
5a63455f 363Message too long (POSIX.1-2001).
fea681da 364.TP
0daa9e92 365.B EMULTIHOP
a0ddea87 366.\" POSIX says "Reserved"
5a63455f 367Multihop attempted (POSIX.1-2001).
fea681da 368.TP
0daa9e92 369.B ENAMETOOLONG
5a63455f 370Filename too long (POSIX.1-2001).
a0ddea87 371.\" ENAVAIL is defined, but appears not to be used
fea681da 372.TP
0daa9e92 373.B ENETDOWN
5a63455f 374Network is down (POSIX.1-2001).
fea681da 375.TP
0daa9e92 376.B ENETRESET
5a63455f 377Connection aborted by network (POSIX.1-2001).
fea681da 378.TP
0daa9e92 379.B ENETUNREACH
5a63455f 380Network unreachable (POSIX.1-2001).
fea681da 381.TP
0daa9e92 382.B ENFILE
5a63455f 383Too many open files in system (POSIX.1-2001).
31071798 384On Linux, this is probably a result of encountering the
4a5c6f9f
MK
385.IR /proc/sys/fs/file-max
386limit (see
387.BR proc (5)).
975c0f87
MK
388.TP
389.B ENOANO
390.\" ENOANO appears to be used by a few drivers
391No anode.
fea681da 392.TP
0daa9e92 393.B ENOBUFS
31071798 394No buffer space available (POSIX.1 (XSI STREAMS option)).
a0ddea87 395.\" ENOCSI is defined but appears to be unused.
fea681da 396.TP
0daa9e92 397.B ENODATA
5a63455f 398No message is available on the STREAM head read queue (POSIX.1-2001).
fea681da 399.TP
0daa9e92 400.B ENODEV
5a63455f 401No such device (POSIX.1-2001).
fea681da 402.TP
0daa9e92 403.B ENOENT
5a63455f 404No such file or directory (POSIX.1-2001).
847e0d88 405.IP
9f895e62
MK
406Typically, this error results when a specified pathname does not exist,
407or one of the components in the directory prefix of a pathname does not exist,
408or the specified pathname is a dangling symbolic link.
fea681da 409.TP
0daa9e92 410.B ENOEXEC
5a63455f 411Exec format error (POSIX.1-2001).
fea681da 412.TP
0daa9e92 413.B ENOKEY
31071798 414Required key not available.
fea681da 415.TP
0daa9e92 416.B ENOLCK
5a63455f 417No locks available (POSIX.1-2001).
fea681da 418.TP
0daa9e92 419.B ENOLINK
a0ddea87 420.\" POSIX says "Reserved"
5a63455f 421Link has been severed (POSIX.1-2001).
fea681da 422.TP
0daa9e92 423.B ENOMEDIUM
31071798 424No medium found.
fea681da 425.TP
0daa9e92 426.B ENOMEM
6386c0c8 427Not enough space/cannot allocate memory (POSIX.1-2001).
fea681da 428.TP
0daa9e92 429.B ENOMSG
5a63455f 430No message of the desired type (POSIX.1-2001).
fea681da 431.TP
0daa9e92 432.B ENONET
31071798 433Machine is not on the network.
fea681da 434.TP
0daa9e92 435.B ENOPKG
31071798 436Package not installed.
fea681da 437.TP
0daa9e92 438.B ENOPROTOOPT
5a63455f 439Protocol not available (POSIX.1-2001).
fea681da 440.TP
0daa9e92 441.B ENOSPC
5a63455f 442No space left on device (POSIX.1-2001).
fea681da 443.TP
0daa9e92 444.B ENOSR
31071798 445No STREAM resources (POSIX.1 (XSI STREAMS option)).
fea681da 446.TP
0daa9e92 447.B ENOSTR
31071798 448Not a STREAM (POSIX.1 (XSI STREAMS option)).
fea681da 449.TP
0daa9e92 450.B ENOSYS
5a63455f 451Function not implemented (POSIX.1-2001).
fea681da 452.TP
0daa9e92 453.B ENOTBLK
31071798 454Block device required.
fea681da 455.TP
0daa9e92 456.B ENOTCONN
5a63455f 457The socket is not connected (POSIX.1-2001).
fea681da 458.TP
0daa9e92 459.B ENOTDIR
5a63455f 460Not a directory (POSIX.1-2001).
fea681da 461.TP
0daa9e92 462.B ENOTEMPTY
5a63455f 463Directory not empty (POSIX.1-2001).
a0ddea87 464.\" ENOTNAM is defined but appears to be unused.
fea681da 465.TP
975c0f87 466.B ENOTRECOVERABLE
5a63455f 467State not recoverable (POSIX.1-2008).
975c0f87 468.TP
0daa9e92 469.B ENOTSOCK
5a63455f 470Not a socket (POSIX.1-2001).
fea681da 471.TP
0daa9e92 472.B ENOTSUP
5a63455f 473Operation not supported (POSIX.1-2001).
fea681da 474.TP
0daa9e92 475.B ENOTTY
5a63455f 476Inappropriate I/O control operation (POSIX.1-2001).
fea681da 477.TP
0daa9e92 478.B ENOTUNIQ
31071798 479Name not unique on network.
fea681da 480.TP
0daa9e92 481.B ENXIO
5a63455f 482No such device or address (POSIX.1-2001).
fea681da 483.TP
0daa9e92 484.B EOPNOTSUPP
5a63455f 485Operation not supported on socket (POSIX.1-2001).
ba39b288 486.IP
2f0af33b
MK
487.RB ( ENOTSUP
488and
489.B EOPNOTSUPP
490have the same value on Linux, but
a0ddea87 491according to POSIX.1 these error values should be distinct.)
fea681da 492.TP
0daa9e92 493.B EOVERFLOW
5a63455f 494Value too large to be stored in data type (POSIX.1-2001).
fea681da 495.TP
975c0f87
MK
496.B EOWNERDEAD
497.\" Used at least by the user-space side of rubost mutexes
5a63455f 498Owner died (POSIX.1-2008).
975c0f87 499.TP
0daa9e92 500.B EPERM
5a63455f 501Operation not permitted (POSIX.1-2001).
fea681da 502.TP
0daa9e92 503.B EPFNOSUPPORT
31071798 504Protocol family not supported.
a0ddea87 505.TP
0daa9e92 506.B EPIPE
5a63455f 507Broken pipe (POSIX.1-2001).
a0ddea87 508.TP
0daa9e92 509.B EPROTO
5a63455f 510Protocol error (POSIX.1-2001).
a0ddea87 511.TP
0daa9e92 512.B EPROTONOSUPPORT
5a63455f 513Protocol not supported (POSIX.1-2001).
a0ddea87 514.TP
0daa9e92 515.B EPROTOTYPE
5a63455f 516Protocol wrong type for socket (POSIX.1-2001).
a0ddea87 517.TP
0daa9e92 518.B ERANGE
31071798 519Result too large (POSIX.1, C99).
a0ddea87 520.TP
0daa9e92 521.B EREMCHG
31071798 522Remote address changed.
a0ddea87 523.TP
0daa9e92 524.B EREMOTE
31071798 525Object is remote.
a0ddea87 526.TP
0daa9e92 527.B EREMOTEIO
31071798 528Remote I/O error.
a0ddea87 529.TP
0daa9e92 530.B ERESTART
31071798 531Interrupted system call should be restarted.
a0ddea87 532.TP
975c0f87
MK
533.B ERFKILL
534.\" ERFKILL appears to be used by various drivers
535Operation not possible due to RF-kill.
536.TP
0daa9e92 537.B EROFS
5a63455f 538Read-only filesystem (POSIX.1-2001).
a0ddea87 539.TP
0daa9e92 540.B ESHUTDOWN
31071798 541Cannot send after transport endpoint shutdown.
a0ddea87 542.TP
0daa9e92 543.B ESPIPE
5a63455f 544Invalid seek (POSIX.1-2001).
a0ddea87 545.TP
0daa9e92 546.B ESOCKTNOSUPPORT
31071798 547Socket type not supported.
a0ddea87 548.TP
0daa9e92 549.B ESRCH
5a63455f 550No such process (POSIX.1-2001).
a0ddea87
MK
551.\" ESRMNT is defined but appears not to be used
552.TP
0daa9e92 553.B ESTALE
5a63455f 554Stale file handle (POSIX.1-2001).
ba39b288 555.IP
31071798 556This error can occur for NFS and for other filesystems.
a0ddea87 557.TP
0daa9e92 558.B ESTRPIPE
31071798 559Streams pipe error.
a0ddea87 560.TP
0daa9e92 561.B ETIME
5db92f96
MK
562Timer expired
563(POSIX.1 (XSI STREAMS option)).
ba39b288 564.IP
c13182ef 565(POSIX.1 says "STREAM
363a3cc9 566.BR ioctl (2)
5db92f96 567timeout".)
a0ddea87 568.TP
0daa9e92 569.B ETIMEDOUT
5a63455f 570Connection timed out (POSIX.1-2001).
975c0f87
MK
571.TP
572.B ETOOMANYREFS
573.\" ETOOMANYREFS seems to be used in net/unix/af_unix.c
574Too many references: cannot splice.
a0ddea87 575.TP
0daa9e92 576.B ETXTBSY
5a63455f 577Text file busy (POSIX.1-2001).
fea681da 578.TP
0daa9e92 579.B EUCLEAN
31071798 580Structure needs cleaning.
fea681da 581.TP
0daa9e92 582.B EUNATCH
31071798 583Protocol driver not attached.
fea681da 584.TP
0daa9e92 585.B EUSERS
31071798 586Too many users.
a0ddea87 587.TP
0daa9e92 588.B EWOULDBLOCK
fea681da 589Operation would block (may be same value as
c13182ef 590.BR EAGAIN )
5a63455f 591(POSIX.1-2001).
a0ddea87 592.TP
0daa9e92 593.B EXDEV
5a63455f 594Improper link (POSIX.1-2001).
fea681da 595.TP
a0ddea87 596.B EXFULL
31071798 597Exchange full.
05432883 598.SH NOTES
fea681da 599A common mistake is to do
e646a1ba 600.PP
a6e2f128 601.in +4n
e646a1ba 602.EX
2bc2f479 603if (somecall() == \-1) {
31a6818e 604 printf("somecall() failed\en");
fea681da
MK
605 if (errno == ...) { ... }
606}
e646a1ba 607.EE
a6e2f128 608.in
e646a1ba 609.PP
fea681da
MK
610where
611.I errno
612no longer needs to have the value it had upon return from
63aa9df0 613.IR somecall ()
05432883 614(i.e., it may have been changed by the
fb186734 615.BR printf (3)).
fea681da
MK
616If the value of
617.I errno
618should be preserved across a library call, it must be saved:
e646a1ba 619.PP
a6e2f128 620.in +4n
e646a1ba 621.EX
2bc2f479 622if (somecall() == \-1) {
fea681da 623 int errsv = errno;
31a6818e 624 printf("somecall() failed\en");
fea681da
MK
625 if (errsv == ...) { ... }
626}
b8302363 627.EE
a6e2f128 628.in
05432883 629.PP
6eb4b782
MK
630On some ancient systems,
631.I <errno.h>
632was not present or did not declare
633.IR errno ,
634so that it was necessary to declare
05432883
MK
635.I errno
636manually
c13182ef 637(i.e.,
6eb4b782 638.IR "extern int errno" ).
05432883 639.BR "Do not do this" .
6eb4b782
MK
640It long ago ceased to be necessary,
641and it will cause problems with modern versions of the C library.
47297adb 642.SH SEE ALSO
00f3b66d 643.BR errno (1), \" In the moreutils package
d7871cf9 644.BR err (3),
37b6aec3 645.BR error (3),
fea681da
MK
646.BR perror (3),
647.BR strerror (3)