由于errno的重要性,在这里翻译一下Linux中man手册关于errno的内容以及errno涉及的要点
#include <string.h>
char *strerror(int errnum);
这个函数将errno映射到错误消息字符串,并返回一个指向这个字符串的指针。
#include
void perror(const char *msg);
perror有类似的功能,只是先加上了一个msg消息|
名字
errno - number of last error
头文件
#include
定义了整数变量errno。由系统调用和某些库函数根据事件来设置它,用以表明哪里有问题。这个值只有当调用的返回表明错误的时候有用,(比如,对于大多数的系统调用是-1,对于大多数的库函数来说是-1或NULL),正确的函数也可以修改errno。 名字 | 解释 | 协议 |
---|---|---|
E2BIG | 参数列表太长 | POSIX.1 |
EACCES | 拒绝访问(permision denied) | POSIX.1 |
EADDRINUSE | 地址已经被使用 | POSIX.1 |
EADDRNOTAVAIL | 地址不可用 | POSIX.1 |
EAFNOSUPPORT | 地址族不支持 | POSIX.1 |
EAGIAN | 资源暂时不可用(可能和EWOULDBLOCK的值相同) | POSIX.1 |
EALREADY | 已经连接 | POSIX.1 |
EBADE | 无效交换 | |
EBADF | 坏的文件描述符 | POSIX.1 |
EBADFD | 文件描述符在坏的状态 | POSIX.1 |
EBADMSG | BAD MESSAGE | POSIX.1 |
EBADR | 无效请求描述符 | |
EBADRQC | 无效请求代码 | |
EBADSLT | Invalid Slot | |
EBUSY | 设备或资源忙 | POSIX.1 |
ECANCELED | 操作取消 | POSIX.1 |
ECHILD | 没有子进程 | POSIX.1 |
ECHRNG | Channel number out of range | |
ECOMM | Communication error on send | |
ECONNABORTED | Connection aborted | POSIX.1 |
ECONNREFUSED | Connection refused | POSIX.1 |
ECONNRESET | Connection reset | POSIX.1 |
EDEADLK | Resource deadlock avoided | POSIX.1 |
EDEADLOCK | synonym for EDEADLK | |
EDESTADDRREQ | Destination address required | POSIX.1 |
EDOM | Mathematics argument out domain of function | POSIX.1 C99 |
EDQUOT | 超过磁盘配额 | POSIX.1 |
EEXIST | 文件存在 | POSIX.1 |
EFAULT | Bad address | POSIX.1 |
EFBIG | 文件太大 | POSIX.1 |
EHOSTDOWN | 主机故障 | |
EHOSTUNREACH | 主机不可达 | POSIX.1 |
EIDRM | Identifier removed | POSIX.1 |
EILSEQ | 非法字节序列 | POSIX.1,C99 |
EINPROGRESS | 正在操作 | POSIX.1 |
EINTR | 中断函数调用 | POSIX.1 |
EINVAL | 无效参数 | POSIX.1 |
EIO | 输入/输出错误 | POSIX.1 |
EISCONN | 套接字已经连接 | POSIX.1 |
EISDIR | 是一个目录 | POSIX.1 |
EISNAM | Is a named type file | POSIX.1 |
EKEYEXPIRED | Key过期了 | |
EKEYREJECTED | Key被服务拒绝了 | |
EKEYREVOKED | Key已经被取消 | |
EL2HLT | Level 2停止 | |
EL2NSYNS | Level 2不同步 | |
EL3HLT | Level 3停止 | |
EL3RST | Level 3停止 | |
ELIBACC | 不能访问所需的共享库 | |
ELIBBAD | 访问了一个坏的共享库 | |
ELIBMAX | 尝试链接过多的共享库 | |
ELIBSCN | a.out中的lib段毁坏了 | |
ELIBEXEC | 不能直接运行一个共享库 | |
ELOOP | 太多层的符号链接 | POSIX.1 |
EMEDIUMTYPE | 错误的中间类型 | |
EMFILE | 太多打开的文件,往往是由于超过getrlimit(2)中描述的RLIMIT_NOFILE资源约束导致的 | POSIX.1 |
EMLINK | 太多的连接 | POSIX.1 |
EMSGSIZE | message太长 | POSIX.1 |
EMULTIHOP | 尝试多跳 | POSIX.1 |
ENAMETOOLONG | 文件名太长 | POSIX.1 |
ENETDOWN | 网络不可用 | POSIX.1 |
ENETRESET | Connection aborted by network | POSIX.1 |
ENETUNREACH | 网络不可达 | POSIX.1 |
ENFILE | 系统中太多打开文件,在Linux可能是遇到了/proc/sys/fs/file-max约束 | POSIX.1 |
ENOBUFS | 没有可用的缓冲 | POSIX.1 |
ENODATA | No message is avaliable on the STREAM head read queue | POSIX.1 |
ENODEV | 没有这个设备 | POSIX.1 |
ENOENT | No such file or directory | POSIX.1 |
ENOEXEC | 执行格式错误 | POSIX.1 |
ENOKEY | Required key not available | POSIX.1 |
ENOLCK | No locks avaliable | POSIX.1 |
ENOLINK | Link has been served | POSIX.1 |
ENOMEDIUM | No medium found | |
ENOMEM | Not enough space | POSIX.1 |
ENOMSG | No message of desired type | POSIX.1 |
ENONET | Machine is not on the network | POSIX.1 |
ENOPKG | Package not installed | POSIX.1 |
ENOPROTOOPT | Protocol not avaliable | POSIX.1 |
ENOSPC | No space left on device | POSIX.1 |
ENOSR | No STREAM resources | POSIX.1 |
ENOSTR | Not a stream | POSIX.1 |
ENOSYS | Function Not implementated | POSIX.1 |
ENOTBLK | Block device required | POSIX.1 |
ENOTCONN | The socket is not connected | POSIX.1 |
ENOTDIR | 不是目录 | POSIX.1 |
ENOTEMPTY | Directory not empty | POSIX.1 |
ENOTSOCK | Not a socket | POSIX.1 |
ENOTSUP | Operation not supported | POSIX.1 |
ENOTTY | Inappropriate I/O control operation | POSIX.1 |
ENOUNIQ | 名字在网络上不唯一 | POSIX.1 |
ENXIO | No such device or address | POSIX.1 |
EOPNOTSUPP | Operation not supported on socket(在Linux它和ENOTSUP有相同的值) | POSIX.1 |
EOVERFLOW | Value too large to be stored in data type | POSIX.1 |
EPERN | 操作不允许 | POSIX.1 |
EPFNOSUPPORT | Protocol family not supported | |
EPIPE | Broken pipe | POSIX.1 |
EPROTO | protocol error | POSIX.1 |
EPROTONOSUPPORT | 协议不支持 | POSIX.1 |
EPROTOTYPE | Protocol wrong type for socket | POSIX.1 |
ERANGE | Result too large | POSIX.1 |
EREMCHG | 远程地址改变 | POSIX.1 |
EREMOTE | Object is remote | POSIX.1 |
EREMOTEIO | Remote I/O error | POSIX.1 |
ERESTART | Interrupted system call should be restarted | |
EROFS | 只读文件系统 | POSIX.1 |
ESHUTDOWN | Cannot send after transport endpoint shutdown | |
ESPIPE | Invalid seek | POSIX.1 |
ESOCKTNOSUPPORT | Socket type not supported | POSIX.1 |
ESRCH | No such process | POSIX.1 |
ESTALE | Stail file handle | POSIX.1 |
ESTRPIPE | Streams pipe error | |
ETIME | 超时的 | POSIX.1 |
ETIMEDOUT | Connection timed out | POSIX.1 |
ETXTBSY | Text file busy | POSIX.1 |
EUCLEAN | Structure needs cleaning | |
EUNATACH | Protocol driver not attached | |
EUSERS | 太多的用户 | |
EWOULDBLOCK | Operation would block(may be same value as EAGAIN) | POSIX.1 |
EXDEV | Improper link | POSIX.1 |
EXFULL | Exchange full |