Transferred from: http://baike.baidu.com/link?url=uX-q7K-TTL-5AFNT-hjhAP6fvgAwvsNkIMqJqJ3GEspYgtQXsovEEzpqmQ3ZmAgql2uG3LluUetAp8uKTm3z5q
Errno is the last error code for the recording system. The code is a value of type int, defined in errno.h
NAMEEditErrno-number of Last Errorif (somecall () = = 1) {printf ("Somecall () failed\n"), if (errno = = ...) { ... }} Such an example does not get the error code generated by the operation of the Somecall function, because it is probably the result of the function of printf. if (somecall () = =-1) {int ERRSV = errno;printf ("Somecall () failed\n"); if (ERRSV = = ...) { ... } This will really get the error code that comes with running the Somecall function. Note: errno is only set when a library function fails. When the function runs successfully, the value of errno is not modified. This means that we cannot determine if there is an error by testing the value of the errno. Conversely, it is only meaningful to check the value of errno when the called function hints that an error has occurred. Viewing error code errno is an important way to debug a program. When an exception occurs in a Linux C API function, the errno variable (include errno.h) is typically assigned an integer value, and different values represent different meanings, which can be inferred by looking at the value. In the actual programming with this trick to solve a lot of the original seemingly inexplicable problems. Some error definitions for errnoEditThe following are mainly from 2.6.32 kernel code in the/usr/include/asm-generic/errno.h and errno-base.h, the output error reason definition summarized as follows: #define EPERM 1/* Operation not Permitted * *
#define ENOENT 2 */No such file or directory */
#define ESRCH 3 */No such process */
#define EINTR 4/* Interrupted system call */
#define EIO 5 */I/O error */
#define ENXIO 6 */No such device or address */
#define E2BIG 7/* Argument list too long */
#define ENOEXEC 8/* Exec format Error */
#define EBADF 9/* Bad file number */
#define ECHILD/* No child processes */
#define EAGAIN/* Try again */
#define ENOMEM/* Out of memory */
#define EACCES/* Permission denied */
#define EFAULT/* Bad address */
#define ENOTBLK/* Block Device required */
#define EBUSY/* Device or resource busy */
#define EEXIST */* File exists */
#define EXDEV */* cross-device link */
#define ENODEV */No such device */
#define ENOTDIR/* Not a directory */
#define EISDIR/* is a directory */
#define EINVAL */* Invalid argument */
#define ENFILE/* File table overflow */
#define EMFILE/* Too many open files */
#define ENOTTY */Not a typewriter */
#define ETXTBSY/* Text file Busy */
#define EFBIG/* File too large */
#define ENOSPC/* No space left on device */
#define ESPIPE/* Illegal seek * *
#define EROFS/* read-only File System */
#define Emlink */Too Many links * *
#define EPIPE */broken pipe */
#define EDOM/* Math argument out of domain of func * *
#define ERANGE/* Math result not representable */
#define EDEADLK//Resource deadlock would occur * *
#define ENAMETOOLONG/*/File name too long */
#define ENOLCK Notoginseng */No record locks available */
#define ENOSYS */Function not implemented */
#define ENOTEMPTY/* Directory not empty */
#define ELOOP/* Too Many symbolic links encountered * *
#define EWOULDBLOCK eagain/* operation would block */
#define ENOMSG * * No message of desired type */
#define EIDRM */Identifier removed */
#define ECHRNG */* Channel number out of range */
#define EL2NSYNC */Level 2 not synchronized */
#define EL3HLT */Level 3 halted */
#define EL3RST/* Level 3 Reset */
#define ELNRNG/* Link number out of range */
#define Eunatch */Protocol driver not attached */
#define ENOCSI/* NO CSI structure available */
#define EL2HLT/* Level 2 halted */
#define EBADE//Invalid Exchange * *
#define EBADR-*/Invalid Request Descriptor */
#define EXFULL/* Exchange full */
#define Enoano/* No anode */
#define EBADRQC-*/Invalid Request code */
#define EBADSLT/* Invalid slot */
#define Edeadlock Edeadlk
#define EBFONT/* Bad font file format */
#define ENOSTR/* Device not a stream */
#define ENODATA/* NO data available */
#define ETIME */* Timer expired */
#define ENOSR */* out of streams resources * *
#define ENONET */Machine was not on the network */
#define ENOPKG/* Package not installed */
#define EREMOTE/* Object is remote */
#define ENOLINK/* Link has been severed */
#define EADV/* Advertise Error */
#define ESRMNT/* Srmount Error */
#define ECOMM/* Communication error on Send */
#define EPROTO/* Protocol Error */
#define EMULTIHOP */multihop attempted */
#define EDOTDOT */RFS specific error */
#define EBADMSG * */NOT a data message */
#define Eoverflow */Value too large for defined data type */
#define ENOTUNIQ/* Name not unique on network */
#define EBADFD */* File descriptor in Bad state */
#define EREMCHG/*/Remote address changed */
#define ELIBACC/* Can not access a needed shared library */
#define ELIBBAD */Accessing a corrupted shared library */
#define ELIBSCN Bayi/* lib section in a.out corrupted */
#define ELIBMAX/attempting to link in too many shared libraries */
#define ELIBEXEC */cannot exec a shared library directly */
#define EILSEQ/* Illegal byte sequence */
#define ERESTART//interrupted system call should be restarted */
#define ESTRPIPE-*/Streams Pipe error */
#define Eusers */Too Many users * *
#define ENOTSOCK */* Socket operation on Non-socket */
#define EDESTADDRREQ */Destination address required */
#define EMSGSIZE/* Message too long */
#define EPROTOTYPE/* Protocol wrong type for socket */
#define ENOPROTOOPT */Protocol Not available */
#define EPROTONOSUPPORT */Protocol not supported */
#define ESOCKTNOSUPPORT 94/* Socket type not supported */
#define EOPNOTSUPP */operation not supported on transport endpoint * *
#define Epfnosupport */Protocol family not supported */
#define Eafnosupport */Address family not supported by protocol */
#define EADDRINUSE 98/* Address already in use */
#define EADDRNOTAVAIL/* Cannot assign requested address * *
#define ENETDOWN/* Network is down */
#define ENETUNREACH 101/* Network is unreachable */
#define ENETRESET 102/* Network dropped connection because of reset */
#define ECONNABORTED 103/* Software caused connection abort */
#define ECONNRESET 104/* Connection Reset by Peer */
#define ENOBUFS */No Buffer space available */
#define EISCONN 106/* Transport endpoint is already connected * *
#define ENOTCONN 107/* Transport endpoint is not connected */
#define ESHUTDOWN 108/* Cannot send after transport endpoint shutdown */
#define ETOOMANYREFS 109/* Too many references:cannot splice * *
#define ETIMEDOUT */Connection timed out */
#define ECONNREFUSED 111/* Connection refused */
#define EHOSTDOWN. */* Host is down */
#define EHOSTUNREACH 113/* No route to host */
#define Ealready */operation already in progress */
#define EINPROGRESS-*/Operation now in progress */
#define ESTALE */* Stale NFS file handle */
#define EUCLEAN 117/* Structure needs cleaning * *
#define ENOTNAM 118/* Not a XENIX named type file */
#define ENAVAIL 119 */No XENIX semaphores Available * *
#define EISNAM/* is a named type file */
#define ENOKEY 126/* Required key not available */
#define EKEYEXPIRED 127/* Key has expired */
#define EKEYREVOKED/* Key has been revoked */
#define EKEYREJECTED 129/* Key was rejected by service */
#define EOWNERDEAD/* Owner died */
#define ENOTRECOVERABLE 131/* State not recoverable */
#define Erfkill */Operation not possible due to Rf-kill * *
#define EHWPOISON 133/* Memory page has hardware error */
errno error code