The errno in Linux
When executing system calls under Linux, a return value typically indicates success or failure, but this value only indicates success or failure, but does not indicate how successful or failed.Errno is to solve this problem,
There are three types of error reporting usages in the C language standard library.1, errnoerrno is defined in the header file as follows
#ifndef errno
extern int errno;
#endif
An external variable errno an implementation-defined
Errno (Error Report) usage in C language, errno Error Report
There are three forms of error reporting in the C language standard library.
1,Errno
Errno is defined in the header file, as follows:
#ifndef errnoextern int errno;#endif
The external
When there is an exception to the C API function in Linux, generally will errno variable (need include errno.h) to assign an integer value, different values to represent different meanings, you can see the value of the reason for the error, in the
The C language provides a global variable errno for program execution. Errno is declared in errno. h.
The following example attempts to open a non-existing file and then outputs the errno value.
# Include
# Include
# Include
# Include
#
Lien000034August 24, 20141. errno variable
The file defines the symbol errno and various constants that can be assigned to it. These constants start with the character E. For example, if errno is equal to the constant eacces, a permission error
Errno can help us find the error message of the system function. For example, the open function, if returned normally, its return value is a non-negative integer. The exception will return-1, and the system function will set the value of errno, so
1. Relationship between printf and fprintf 1 printf ()# Include Int printf (const char * format ,...);The printf () function prints the output to stdout (standard output) and other parameters according to the format given by format. For the output
Copyright statement: reprinted in the form of hyperlink to indicate the original source and author information and this statement http://www.blogbus.com/wzgyantai-logs/24470871.html
When the C api function in linux encounters an exception, the
All along, the personal concept of only non-blocking socket will produce eagain error, meaning is currently not read and write, as long as you continue to try again. When we recently redis an error in the module to correct this concept of my mistake.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.