mirror of https://github.com/mkerrisk/man-pages
Martin Schulze, mtk
Removed errno declaration from prototype, added notes on historical need for this declaration. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=174175
This commit is contained in:
parent
3124d276bf
commit
0543288347
49
man3/errno.3
49
man3/errno.3
|
@ -22,24 +22,30 @@
|
||||||
.\"
|
.\"
|
||||||
.\" 5 Oct 2002, Modified by Michael Kerrisk <mtk-manpages@gmx.net>
|
.\" 5 Oct 2002, Modified by Michael Kerrisk <mtk-manpages@gmx.net>
|
||||||
.\" Updated for POSIX 1003.1 2001
|
.\" Updated for POSIX 1003.1 2001
|
||||||
|
.\" 2004-12-17 Martin Schulze <joey@infodrom.org>, mtk
|
||||||
|
.\" Removed errno declaration prototype, added notes
|
||||||
.\"
|
.\"
|
||||||
.TH ERRNO 3 2002-10-05 "" "Library functions"
|
.TH ERRNO 3 2004-12-17 "" "Library functions"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
errno \- number of last error
|
errno \- number of last error
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B #include <errno.h>
|
.B #include <errno.h>
|
||||||
.sp
|
.\".sp
|
||||||
.BI "extern int " errno ;
|
.\".BI "extern int " errno ;
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
The integer
|
The
|
||||||
.B errno
|
.I <errno.h>
|
||||||
is set by system calls (and some library functions) to indicate
|
header file defines the integer variable
|
||||||
what went wrong. Its value is significant only when the call
|
.B errno ,
|
||||||
returned an error (usually \-1), and a library function that does succeed
|
which is set by system calls and some library functions in the event
|
||||||
|
of an error to indicate what went wrong.
|
||||||
|
Its value is significant only when the call
|
||||||
|
returned an error (usually \-1), and a function that does succeed
|
||||||
is allowed to change
|
is allowed to change
|
||||||
.BR errno .
|
.BR errno .
|
||||||
|
|
||||||
Sometimes, when \-1 is also a legal return value one has to zero
|
Sometimes, when \-1 is also a valid successful return value
|
||||||
|
one has to zero
|
||||||
.B errno
|
.B errno
|
||||||
before the call in order to detect possible errors.
|
before the call in order to detect possible errors.
|
||||||
|
|
||||||
|
@ -50,7 +56,11 @@ does not affect its value in any other thread.
|
||||||
|
|
||||||
Valid error numbers are all non-zero; \fBerrno\fR is never set to zero
|
Valid error numbers are all non-zero; \fBerrno\fR is never set to zero
|
||||||
by any library function. All the error names specified by POSIX.1
|
by any library function. All the error names specified by POSIX.1
|
||||||
must have distinct values.
|
must have distinct values, with the exception of
|
||||||
|
.B EAGAIN
|
||||||
|
and
|
||||||
|
.BR EWOULDBLOCK ,
|
||||||
|
which may be the same.
|
||||||
|
|
||||||
.\" FIXME EILSEQ is in C99.
|
.\" FIXME EILSEQ is in C99.
|
||||||
POSIX.1 (2001 edition) lists the following symbolic error names. Of
|
POSIX.1 (2001 edition) lists the following symbolic error names. Of
|
||||||
|
@ -300,7 +310,7 @@ Operation would block (may be same value as
|
||||||
.TP
|
.TP
|
||||||
.B EXDEV
|
.B EXDEV
|
||||||
Improper link
|
Improper link
|
||||||
.SH NOTE
|
.SH NOTES
|
||||||
A common mistake is to do
|
A common mistake is to do
|
||||||
.RS
|
.RS
|
||||||
.nf
|
.nf
|
||||||
|
@ -315,7 +325,9 @@ if (somecall() == -1) {
|
||||||
where
|
where
|
||||||
.I errno
|
.I errno
|
||||||
no longer needs to have the value it had upon return from
|
no longer needs to have the value it had upon return from
|
||||||
.IR somecall() .
|
.IR somecall()
|
||||||
|
(i.e., it may have been changed by the
|
||||||
|
.IR printf() ).
|
||||||
If the value of
|
If the value of
|
||||||
.I errno
|
.I errno
|
||||||
should be preserved across a library call, it must be saved:
|
should be preserved across a library call, it must be saved:
|
||||||
|
@ -329,6 +341,19 @@ if (somecall() == -1) {
|
||||||
}
|
}
|
||||||
.fi
|
.fi
|
||||||
.RE
|
.RE
|
||||||
|
.PP
|
||||||
|
It was common in traditional C to declare
|
||||||
|
.I errno
|
||||||
|
manually
|
||||||
|
(i.e.,
|
||||||
|
.IR "extern int errno" )
|
||||||
|
instead of including
|
||||||
|
.IR <errno.h> .
|
||||||
|
.BR "Do not do this" .
|
||||||
|
It will not work with modern versions of the C library.
|
||||||
|
However, on (very) old Unix systems, there may be no
|
||||||
|
.I <errno.h>
|
||||||
|
and the declaration is needed.
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.BR perror (3),
|
.BR perror (3),
|
||||||
.BR strerror (3)
|
.BR strerror (3)
|
||||||
|
|
Loading…
Reference in New Issue