打印Linux系统错误编码

系统运维工程师和系统开发工程师在日常工作中,经常会遇到此类问题“当你进行了一些不当操作,系统会给你错误提示”,这些错误提示在操作系统中都是错误编码的,每一个提示对应一个错误编码,错误编码供程序代码中方便调用,接下来我们会打印出linux操作系统的错误编码及提示,如下:

一、系统环境

系统版本:

内核版本:

二、程序代码

代码如下:

三、编译运行

结果如下:

[root@CentOS6 erro_num]# gcc error_num.c [root@centos6 erro_num]# ./a.out 0:Success1:Operation not permitted2:No such file or directory3:No such process4:Interrupted system call5:Input/output error6:No such device or address7:Argument list too long8:Exec format error9:Bad file descriptor10:No child processes11:Resource temporarily unavailable12:Cannot allocate memory13:Permission denied14:Bad address15:Block device required16:Device or resource busy17:File exists18:Invalid cross-device link19:No such device20:Not a directory21:Is a directory22:Invalid argument23:Too many open files in system24:Too many open files25:Inappropriate ioctl for device26:Text file busy27:File too large28:No space left on device29:Illegal seek30:Read-only file system31:Too many links32:Broken pipe33:Numerical argument out of domain34:Numerical result out of range35:Resource deadlock avoided36:File name too long37:No locks available38:Function not implemented39:Directory not empty40:Too many levels of symbolic links41:Unknown error 4142:No message of desired type43:Identifier removed44:Channel number out of range45:Level 2 not synchronized46:Level 3 halted47:Level 3 reset48:Link number out of range49:Protocol driver not attached50:No CSI structure available51:Level 2 halted52:Invalid exchange53:Invalid request descriptor54:Exchange full55:No anode56:Invalid request code57:Invalid slot58:Unknown error 5859:Bad font file format60:Device not a stream61:No data available62:Timer expired63:Out of streams resources64:Machine is not on the network65:Package not installed66:Object is remote67:Link has been severed68:Advertise error69:Srmount error70:Communication error on send71:Protocol error72:Multihop attempted73:RFS specific error74:Bad message75:Value too large for defined data type76:Name not unique on network77:File descriptor in bad state78:Remote address changed79:Can not access a needed shared library80:Accessing a corrupted shared library81:.lib section in a.out corrupted82:Attempting to link in too many shared libraries83:Cannot exec a shared library directly84:Invalid or incomplete multibyte or wide character85:Interrupted system call should be restarted86:Streams pipe error87:Too many users88:Socket operation on non-socket89:Destination address required90:Message too long91:Protocol wrong type for socket92:Protocol not available93:Protocol not supported94:Socket type not supported95:Operation not supported96:Protocol family not supported97:Address family not supported by protocol98:Address already in use99:Cannot assign requested address100:Network is down101:Network is unreachable102:Network dropped connection on reset103:Software caused connection abort104:Connection reset by peer105:No buffer space available106:Transport endpoint is already connected107:Transport endpoint is not connected108:Cannot send after transport endpoint shutdown109:Too many references: cannot splice110:Connection timed out111:Connection refused112:Host is down113:No route to host114:Operation already in progress115:Operation now in progress116:Stale NFS file handle117:Structure needs cleaning118:Not a XENIX named type file119:No XENIX semaphores available120:Is a named type file121:Remote I/O error122:Disk quota exceeded123:No medium found124:Wrong medium type125:Operation canceled126:Required key not available127:Key has expired128:Key has been revoked129:Key was rejected by service130:Owner died131:State not recoverable

如果你看过nginx-1.0.10源码,里面有一个类似的错误编码预定义 135个,在objs/ngx_auto_config.h 中,#define NGX_SYS_NERR135,事实证明,,这种思想是非常可取的,我们自己写软件的时候,不妨尝试一下?

本文永久更新链接地址:

辽远或偏僻的地方,而会常常想起这一次的旅行,

打印Linux系统错误编码

相关文章:

你感兴趣的文章:

标签云: