标题: 关于errno [打印本页] 作者: phoxia 时间: 2011-08-09 15:02 标题: 关于errno DESCRIPTION
The <errno.h> header file defines the integer variable errno, 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 (usu鈥[m
ally -1), and a function that does succeed is allowed to change errno.
Sometimes, when -1 is also a valid successful return value one has to zero errno before the call in order to detect pos鈥[m
sible errors.
errno is defined by the ISO C standard to be a modifiable lvalue of type int, and must not be explicitly declared; errno
may be a macro. errno is thread-local; setting it in one thread does not affect its value in any other thread. Valid error numbers are all non-zero; errno is never set to zero by any library function. All the error names specified
by POSIX.1 must have distinct values, with the exception of EAGAIN and EWOULDBLOCK, which may be the same.
Below is a list of the symbolic error names that are defined on Linux. Some of these are marked POSIX.1, indicating that
the name is defined by POSIX.1-2001, or C99, indicating that the name is defined by C99.