常见的Linux系统错误码

合集下载

linux中对errno是EINTR的处理

linux中对errno是EINTR的处理

linux中对errno是EINTR的处理慢系统调用(slow system call):此术语适用于那些可能永远阻塞的系统调用。

永远阻塞的系统调用是指调用有可能永远无法返回,多数网络支持函数都属于这一类。

如:若没有客户连接到服务器上,那么服务器的accept调用就没有返回的保证。

EINTR错误的产生:当阻塞于某个慢系统调用的一个进程捕获某个信号且相应信号处理函数返回时,该系统调用可能返回一个EINTR错误。

例如:在socket服务器端,设置了信号捕获机制,有子进程,当在父进程阻塞于慢系统调用时由父进程捕获到了一个有效信号时,内核会致使accept返回一个EINTR错误(被中断的系统调用)。

当碰到EINTR错误的时候,可以采取有一些可以重启的系统调用要进行重启,而对于有一些系统调用是不能够重启的。

例如:accept、read、write、select、和open之类的函数来说,是可以进行重启的。

不过对于套接字编程中的connect 函数我们是不能重启的,若connect函数返回一个EINTR错误的时候,我们不能再次调用它,否则将立即返回一个错误。

针对connect不能重启的处理方法是,必须调用select来等待连接完成。

在 linux 或者 unix 环境中, errno 是一个十分重要的部分。

在调用的函数出现问题的时候,我们可以通过 errno 的值来确定出错的原因,这就会涉及到一个问题,那就是如何保证 errno 在多线程或者进程中安全?我们希望在多线程或者进程中,每个线程或者进程都拥有自己独立和唯一的一个 errno ,这样就能够保证不会有竞争条件的出现。

一般而言,编译器会自动保证 errno 的安全性,但是为了妥善期间,我们希望在写 makefile 的时候把 _LIBC_REENTRANT 宏定义,比如我们在检查 <bits/errno.h> 文件中发现如下的定义:C代码# ifndef __ASSEMBLER__/* Function to get address of global `errno' variable. */extern int *__errno_location (void) __THROW __attribute__ ((__const__));# if !defined _LIBC || defined _LIBC_REENTRANT/* When using threads, errno is a per-thread value. */# define errno (*__errno_location ())# endif# endif /* !__ASSEMBLER__ */#endif /* _ERRNO_H */也就是说,在没有定义 __LIBC 或者定义 _LIBC_REENTRANT 的时候, errno 是多线程 / 进程安全的。

Linux错误码大全(建议收藏)

Linux错误码大全(建议收藏)

Linux错误码大全查看错误代码errno是调试程序的一个重要方法。

当linuc C api函数发生异常时,一般会将errno变量(需include errno.h)赋一个整数值,不同的值表示不同的含义,可以通过查看该值推测出错的原因。

在实际编程中用这一招解决了不少原本看来莫名其妙的问题。

比较麻烦的是每次都要去linux源代码里面查找错误代码的含义,现在把它贴出来,以后需要查时就来这里看了。

1-34号错误号是在内核源码的include/asm-generic/errno-base.h定义35-132则是在include/asm-generic/errno.h中定义剩下还有一些更大的错误号是留给内核级别的,如系统调用等,用户程序一般是看不见的这些号的,Ubuntu9.10中/usr/src/linux-headers-2.6.31-21-generic/include/linux/errno.h#ifndef _ASM_GENERIC_ERRNO_BASE_H#define _ASM_GENERIC_ERRNO_BASE_H#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 10 /*No child processes */ #define EAGAIN 11 /*Try again */#define ENOMEM 12 /*Out of memory */#define EACCES 13 /*Permission denied */ #define EFAULT 14 /*Bad address */#define ENOTBLK 15 /*Block device required */ #define EBUSY16 /*Device or resource busy */ #define EEXIST 17 /*File exists */#define EXDEV 18 /*Cross-device link */#define ENODEV 19 /*No such device */#define ENOTDIR 20 /*Not a directory */#define EISDIR 21 /*Is a directory */#define EINVAL 22 /*Invalid argument */#define ENFILE 23 /*File table overflow */#define EMFILE 24 /*Too many open files */#define ENOTTY 25 /*Not a typewriter */#define ETXTBSY 26 /*Text file busy */#define EFBIG 27 /*File too large */#define ENOSPC 28 /*No space left on device */ #define ESPIPE 29 /*Illegal seek */#define EROFS 30 /*Read-only file system */#define EMLINK 31 /*Too many links */#define EPIPE 32 /*Broken pipe */#define EDOM 33 /*Math argument out of domain of func */#define ERANGE 34 /*Math result not representable */#endif#include#define EDEADLK 35 /*Resource deadlock would occur */ #define ENAMETOOLONG 36 /*File name too long */#define ENOLCK 37 /*No record locks available */ #define ENOSYS 38 /*Function not implemented */ #defineENOTEMPTY 39 /*Directory not empty */#define ELOOP 40 /*Too many symbolic links encountered */#define EWOULDBLOCK EAGAIN /*Operation would block */ #define ENOMSG 42 /*No message of desired type */ #define EIDRM 43 /*Identifier removed */#define ECHRNG 44 /*Channel number out of range */ #define EL2NSYNC 45 /*Level 2 not synchronized */ #define EL3HLT 46 /*Level 3 halted */#define EL3RST 47 /*Level 3 reset */#define ELNRNG 48 /*Link number out of range */#define EUNATCH 49 /*Protocol driver not attached */ #define ENOCSI 50 /*No CSI structure available */ #define EL2HLT 51 /*Level 2 halted */#define EBADE 52 /*Invalid exchange */#define EBADR 53 /*Invalid request descriptor */ #define EXFULL 54 /*Exchange full */#define ENOANO 55 /*No anode */#define EBADRQC 56 /*Invalid request code */ #define EBADSLT 57 /*Invalid slot */#define EDEADLOCK EDEADLK#define EBFONT 59 /*Bad font file format */#define ENOSTR 60 /*Device not a stream */#define ENODATA 61 /*No data available */#define ETIME 62 /*Timer expired */#define ENOSR 63 /*Out of streams resources */#define ENONET 64 /*Machine is not on the network */ #define ENOPKG 65 /*Package not installed */ #define EREMOTE 66 /*Object is remote */#define ENOLINK 67 /*Link has been severed */ #define EADV 68 /*Advertise error */#define ESRMNT 69 /*Srmount error */#define ECOMM 70 /*Communication error on send */ #define EPROTO 71 /*Protocol error */#define EMULTIHOP 72 /*Multihop attempted */#define EDOTDOT 73 /*RFS specific error */#define EBADMSG 74 /*Not a data message */#define EOVERFLOW 75 /*Value too large for defined data type */#define ENOTUNIQ 76 /*Name not unique on network */#define EBADFD 77 /*File descriptor in bad state */ #define EREMCHG 78 /*Remote address changed */ #define ELIBACC 79 /*Can not access a needed shared library */#define ELIBBAD 80 /*Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */#define ELIBMAX 82 /*Attempting to link in too many shared libraries */#define ELIBEXEC 83 /*Cannot exec a shared library directly */ #define EILSEQ 84 /*Illegal byte sequence */#define ERESTART 85 /*Interrupted system call should be restarted */#define ESTRPIPE 86 /*Streams pipe error */#define EUSERS 87 /*Too many users */#define ENOTSOCK 88 /*Socket operation on non-socket */#define EDESTADDRREQ 89 /*Destination address required */ #define EMSGSIZE 90 /*Message too long */#define EPROTOTYPE 91 /*Protocol wrong type for socket */ #define ENOPROTOOPT 92 /*Protocol not available */#define EPROTONOSUPPORT 93 /*Protocol not supported */ #define ESOCKTNOSUPPORT 94 /*Socket type not supported */ #define EOPNOTSUPP 95 /*Operation not supported on transport endpoint */#define EPFNOSUPPORT 96 /*Protocol family not supported */ #define EAFNOSUPPORT 97 /*Address family not supported by protocol */#define EADDRINUSE 98 /*Address already in use */#define EADDRNOTAVAIL 99 /*Cannot assign requested address */#define ENETDOWN 100 /*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 105 /*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 /*T oo many references: cannot splice */#define ETIMEDOUT 110 /*Connection timed out */#define ECONNREFUSED 111 /*Connection refused */ #define EHOSTDOWN 112 /*Host is down */#define EHOSTUNREACH 113 /*No route to host */#define EALREADY 114 /*Operation already in progress */ #define EINPROGRESS 115 /*Operation now in progress */ #define ESTALE 116 /*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 120 /*Is a named type file */ #define EREMOTEIO 121 /*Remote I/O error */#define EDQUOT 122 /*Quota exceeded */#define ENOMEDIUM 123 /*No medium found */#define EMEDIUMTYPE 124 /*Wrong medium type *#define ECANCELED 125 / *操作已取消*/#define ENOKEY 126 / *必需的密钥不可用*/ #define EKEYEXPIRED 127 / *密钥已过期*/#define EKEYREVOKED 128 / *密钥已被撤销*/#define EKEYREJECTED 129 / *密钥被服务拒绝*// *用于强大的互斥体*/#define EOWNERDEAD 130 / *所有者死亡*/#define ENOTRECOVERABLE 131 / *状态不可恢复*/#define ERFKILL 132 / *由于射频杀死*/#ifdef __KERNEL__/ **用户程序切勿看到这些内容。

Linux网络编程socket错误码分析

Linux网络编程socket错误码分析

Linux网络编程socket错误分析socket错误码:EINTR:4阻塞的操作被取消阻塞的调用打断。

如设置了发送接收超时,就会遇到这种错误。

只能针对阻塞模式的socket。

读,写阻塞的socket时,-1返回,错误号为INTR。

另外,如果出现EINTR即errno为4,错误描述Interrupted system call,操作也应该继续。

如果recv 的返回值为0,那表明连接已经断开,接收操作也应该结束。

ETIMEOUT:1101、操作超时。

一般设置了发送接收超时,遇到网络繁忙的情况,就会遇到这种错误。

2、服务器做了读数据做了超时限制,读时发生了超时。

3、错误被描述为“connect time out”,即“连接超时”,这种情况一般发生在服务器主机崩溃。

此时客户TCP 将在一定时间内(依具体实现)持续重发数据分节,试图从服务TCP 获得一个ACK 分节。

当最终放弃尝试后(此时服务器未重新启动),内核将会向客户进程返回ETIMEDOUT 错误。

如果某个中间路由器判定该服务器主机已经不可达,则一般会响应“destination unreachable”-“目的地不可达”的ICMP消息,相应的客户进程返回的错误是EHOSTUNREACH 或ENETUNREACH。

当服务器重新启动后,由于TCP 状态丢失,之前所有的连接信息也不存在了,此时对于客户端发来请求将回应RST。

如果客户进程对检测服务器主机是否崩溃很有必要,要求即使客户进程不主动发送数据也能检测出来,那么需要使用其它技术,如配置SO_KEEPALIVE Socket 选项,或实现某些心跳函数。

EAGAIN:1、Send返回值小于要发送的数据数目,会返回EAGAIN和EINTR。

2、recv 返回值小于请求的长度时说明缓冲区已经没有可读数据,但再读不一定会触发EAGAIN,有可能返回0表示TCP连接已被关闭。

3、当socket是非阻塞时,如返回此错误,表示写缓冲队列已满,可以做延时后再重试.4、在Linux进行非阻塞的socket接收数据时经常出现Resource temporarily unavailable,errno 代码为11(EAGAIN),表明在非阻塞模式下调用了阻塞操作,在该操作没有完成就返回这个错误,这个错误不会破坏socket的同步,不用管它,下次循环接着recv就可以。

Linux操作系统错误代码解释 (中英文对照)

Linux操作系统错误代码解释 (中英文对照)

中英文对照Linux 操作系统错误代码解释(zhouyutang@ linuxcman@)OS error code 0: Success操作系统错误代码0:成功OS error code 1: Operation not permitted操作系统错误代码1:操作不允许OS error code 2: No such file or directory操作系统错误代码2:没有这样的文件或目录OS error code 3: No such process操作系统错误代码3:没有这样的过程OS error code 4: Interrupted system call操作系统错误代码4:中断的系统调用OS error code 5: Input/output error操作系统错误代码5:输入/输出错误OS error code 6: No such device or address操作系统错误代码6:没有这样的设备或地址OS error code 7: Argument list too long操作系统错误代码7:参数列表太长OS error code 8: Exec format error操作系统错误代码8:执行格式错误OS error code 9: Bad file descriptor操作系统错误代码9:坏的文件描述符OS error code 10: No child processes操作系统错误代码10:无子过程OS error code 11: Resource temporarily unavailable 操作系统错误代码11:资源暂时不可用OS error code 12: Cannot allocate memory操作系统错误代码12:无法分配内存OS error code 13: Permission denied操作系统错误代码13:权限被拒绝OS error code 14: Bad address操作系统错误代码14:错误的地址OS error code 15: Block device required操作系统错误代码15:需要块设备OS error code 16: Device or resource busy操作系统错误代码16:设备或资源忙OS error code 17: File exists操作系统错误代码17:文件已经存在OS error code 18: Invalid cross-device link操作系统错误代码18:无效的跨设备链接OS error code 19: No such device操作系统错误代码19:没有这样的设备OS error code 20: Not a directory操作系统错误代码20:不是一个目录OS error code 21: Is a directory操作系统错误代码21:是一个目录OS error code 22: Invalid argument操作系统错误代码22:无效参数OS error code 23: Too many open files in system操作系统错误代码23:打开太多的文件系统OS error code 24: Too many open files操作系统错误代码24:打开的文件太多OS error code 25: Inappropriate ioctl for device操作系统错误代码25:不适当的设备ioctl使用OS error code 26: Text file busy操作系统错误代码26:文本文件忙OS error code 27: File too large操作系统错误代码27:文件太大OS error code 28: No space left on device操作系统错误代码28:设备上没有空间OS error code 29: Illegal seek操作系统错误代码29:非法搜索OS error code 30: Read-only file system操作系统错误代码30:只读文件系统OS error code 31: Too many links操作系统错误代码31:链接过多OS error code 32: Broken pipe操作系统错误代码32:管道破裂OS error code 33: Numerical argument out of domain 操作系统错误代码33:超出域的数值参数OS error code 34: Numerical result out of range操作系统错误代码34:数值结果超出范围OS error code 35: Resource deadlock avoided操作系统错误代码35:避免资源死锁OS error code 36: File name too long操作系统错误代码36:文件名太长OS error code 37: No locks available操作系统错误代码37:没有可用锁OS error code 38: Function not implemented操作系统错误代码38:功能没有实现OS error code 39: Directory not empty操作系统错误代码39:目录非空OS error code 40: Too many levels of symbolic links 操作系统错误代码40:符号链接层次太多OS error code 42: No message of desired type操作系统错误代码42:没有期望类型的消息OS error code 43: Identifier removed操作系统错误代码43:标识符删除OS error code 44: Channel number out of range操作系统错误代码44:通道数目超出范围OS error code 45: Level 2 not synchronized操作系统错误代码45:2级不同步OS error code 46: Level 3 halted操作系统错误代码46:3级终止OS error code 47: Level 3 reset操作系统错误代码47:3级复位OS error code 48: Link number out of range操作系统错误代码48:链接数超出范围OS error code 49: Protocol driver not attached 操作系统错误代码49:协议驱动程序没有连接OS error code 50: No CSI structure available 操作系统错误代码50:没有可用的CSI结构OS error code 51: Level 2 halted操作系统错误代码51:2级中断OS error code 52: Invalid exchange操作系统错误代码52:无效的交换OS error code 53: Invalid request descriptor 操作系统错误代码53:无效的请求描述符OS error code 54: Exchange full操作系统错误代码54:交换空间满OS error code 55: No anode操作系统错误代码55:阳极不存在OS error code 56: Invalid request code操作系统错误代码56:无效的请求代码OS error code 57: Invalid slot操作系统错误代码57:无效的槽OS error code 59: Bad font file format操作系统错误代码59:错误的字体文件格式OS error code 60: Device not a stream操作系统错误代码60:设备不属于流类型OS error code 61: No data available操作系统错误代码61:无可用数据OS error code 62: Timer expired操作系统错误代码62:超时OS error code 63: Out of streams resources操作系统错误代码63:超出流资源范围OS error code 64: Machine is not on the network 操作系统错误代码64:主机不在网络上OS error code 65: Package not installed操作系统错误代码65:软件包没有安装OS error code 66: Object is remote操作系统错误代码66:对象是远程的OS error code 67: Link has been severed操作系统错误代码67:链接被切断OS error code 68: Advertise error操作系统错误代码68:广告错误OS error code 69: Srmount error操作系统错误代码69:srmount错误OS error code 70: Communication error on send 操作系统错误代码70:发送数据时通讯错误OS error code 71: Protocol error操作系统错误代码71:协议错误OS error code 72: Multihop attempted操作系统错误代码72:企图进行多次跳转OS error code 73: RFS specific error操作系统错误代码73:RFS类型错误OS error code 74: Bad message操作系统错误代码74:坏消息OS error code 75: Value too large for defined data type操作系统错误代码75:数值超过对于给定的数据类型OS error code 76: Name not unique on network操作系统错误代码76:主机名在网络上不是唯一OS error code 77: File descriptor in bad state操作系统错误代码77:坏状态的文件描述符OS error code 78: Remote address changed操作系统错误代码78:远端地址改变OS error code 79: Can not access a needed shared library操作系统错误代码79:无法访问需要的共享库OS error code 80: Accessing a corrupted shared library操作系统错误代码80:访问了一个损坏的共享库OS error code 81: .lib section in a.out corrupted操作系统错误代码81:a. out文件中的.lib段损坏。

Linux系统编译安装常见错误处理方法

Linux系统编译安装常见错误处理方法

5.Configure: error: libjpeg.(a|so) not found
# yum install libjpeg libjpeg-devel
6.Configure: error: libpng.(also) not found.
# yum install libpng libpng-devel
13.Configure: error: Cannot find ldap.h
# yum install openldap-devel
本篇文章来源于 Linux公社网站() 原文链接:/Linux/2011-04/34622.htm
再php:~/:./configure …… --with-gd=/usr/local/gd2 ……
1) Configure: error: xml2-config not found. Please check your libxml2 installation.
Solutions :
Solutions :
Quote: # yum install unixODBC-devel
12) Configure: error: Cannot find pspell
Solutions :
Quote: # yum install pspell-devel
13) configure: error: mcrypt.h not found. Please reinstall libmcrypt.
7) Configure: error: freetype.h not found.
Solutions :
Quote: #yum install freetype-devel

linux系统错误码大全

linux系统错误码大全

linux系统错误码⼤全#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 /* Arg list too long */#define ENOEXEC 8 /* Exec format error */#define EBADF 9 /* Bad file number */#define ECHILD 10 /* No child processes */#define EAGAIN 11 /* Try again */#define ENOMEM 12 /* Out of memory */#define EACCES 13 /* Permission denied */#define EFAULT 14 /* Bad address */#define ENOTBLK 15 /* Block device required */#define EBUSY 16 /* Device or resource busy */#define EEXIST 17 /* File exists */#define EXDEV 18 /* Cross-device link */#define ENODEV 19 /* No such device */#define ENOTDIR 20 /* Not a directory */#define EISDIR 21 /* Is a directory */#define EINVAL 22 /* Invalid argument */#define ENFILE 23 /* File table overflow */#define EMFILE 24 /* Too many open files */#define ENOTTY 25 /* Not a typewriter */#define ETXTBSY 26 /* Text file busy */#define EFBIG 27 /* File too large */#define ENOSPC 28 /* No space left on device */#define ESPIPE 29 /* Illegal seek */#define EROFS 30 /* Read-only file system */#define EMLINK 31 /* Too many links */#define EPIPE 32 /* Broken pipe */#define EDOM 33 /* Math argument out of domain of func */#define ERANGE 34 /* Math result not representable */#define EDEADLK 35 /* Resource deadlock would occur */#define ENAMETOOLONG 36 /* File name too long */#define ENOLCK 37 /* No record locks available */#define ENOSYS 38 /* Function not implemented */#define ENOTEMPTY 39 /* Directory not empty */#define ELOOP 40 /* Too many symbolic links encountered */#define EWOULDBLOCK EAGAIN /* Operation would block */#define ENOMSG 42 /* No message of desired type */#define EIDRM 43 /* Identifier removed */#define ECHRNG 44 /* Channel number out of range */#define EL2NSYNC 45 /* Level 2 not synchronized */#define EL3HLT 46 /* Level 3 halted */#define EL3RST 47 /* Level 3 reset */#define ELNRNG 48 /* Link number out of range */#define EUNATCH 49 /* Protocol driver not attached */#define ENOCSI 50 /* No CSI structure available */#define EL2HLT 51 /* Level 2 halted */#define EBADE 52 /* Invalid exchange */#define EBADR 53 /* Invalid request descriptor */#define EXFULL 54 /* Exchange full */#define ENOANO 55 /* No anode */#define EBADRQC 56 /* Invalid request code */#define EBADSLT 57 /* Invalid slot */#define EDEADLOCK EDEADLK#define EBFONT 59 /* Bad font file format */#define ENOSTR 60 /* Device not a stream */#define ENODATA 61 /* No data available */#define ETIME 62 /* Timer expired */#define ENOSR 63 /* Out of streams resources */#define ENONET 64 /* Machine is not on the network */#define ENOPKG 65 /* Package not installed */#define EREMOTE 66 /* Object is remote */#define ENOLINK 67 /* Link has been severed */#define EADV 68 /* Advertise error */#define ESRMNT 69 /* Srmount error */#define ECOMM 70 /* Communication error on send */#define EPROTO 71 /* Protocol error */#define EMULTIHOP 72 /* Multihop attempted */#define EDOTDOT 73 /* RFS specific error */#define EBADMSG 74 /* Not a data message */#define EOVERFLOW 75 /* Value too large for defined data type */#define ENOTUNIQ 76 /* Name not unique on network */#define EBADFD 77 /* File descriptor in bad state */#define EREMCHG 78 /* Remote address changed */#define ELIBACC 79 /* Can not access a needed shared library */#define ELIBBAD 80 /* Accessing a corrupted shared library */#define ELIBSCN 81 /* .lib section in a.out corrupted */#define ELIBMAX 82 /* Attempting to link in too many shared libraries */#define ELIBEXEC 83 /* Cannot exec a shared library directly */#define EILSEQ 84 /* Illegal byte sequence */#define ERESTART 85 /* Interrupted system call should be restarted */#define ESTRPIPE 86 /* Streams pipe error */#define EUSERS 87 /* Too many users */#define ENOTSOCK 88 /* Socket operation on non-socket */#define EDESTADDRREQ 89 /* Destination address required */#define EMSGSIZE 90 /* Message too long */#define EPROTOTYPE 91 /* Protocol wrong type for socket */#define ENOPROTOOPT 92 /* Protocol not available */#define EPROTONOSUPPORT 93 /* Protocol not supported */#define ESOCKTNOSUPPORT 94 /* Socket type not supported */#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */#define EAFNOSUPPORT 97 /* Address family not supported by protocol */#define EADDRINUSE 98 /* Address already in use */#define EADDRNOTAVAIL 99 /* Cannot assign requested address */#define ENETDOWN 100 /* 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 105 /* 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 110 /* Connection timed out */#define ECONNREFUSED 111 /* Connection refused */#define EHOSTDOWN 112 /* Host is down */#define EHOSTUNREACH 113 /* No route to host */#define EALREADY 114 /* Operation already in progress */#define EINPROGRESS 115 /* Operation now in progress */#define ESTALE 116 /* 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 120 /* Is a named type file */#define EREMOTEIO 121 /* Remote I/O error */#define EDQUOT 122 /* Quota exceeded */#define ENOMEDIUM 123 /* No medium found */#define EMEDIUMTYPE 124 /* Wrong medium type */。

linux 高压力 connection reset by peer 系统参数 -回复

linux 高压力 connection reset by peer 系统参数 -回复

linux 高压力connection reset by peer 系统参数-回复Linux系统中出现"connection reset by peer"的错误提示是指在网络传输过程中,被对端主动关闭连接或发生了连接异常导致连接被重置。

这种错误常见于高压力连接场景下,可能是由于资源不足、网络延迟、负载过重等原因导致的。

为了解决这个问题,可以通过调整系统参数来优化网络连接,保证系统的稳定性和可靠性。

第一步:了解"connection reset by peer"错误的原因和特征(150-300字)"connection reset by peer"错误提示意味着在网络传输过程中遇到了连接异常。

这种错误通常由于对端关闭连接、网络延迟、资源不足或负载过重等原因引起。

在高压力连接场景下,如并发请求较多或数据传输较大的情况下,可能会出现这个错误。

它会导致连接异常中断,影响数据传输的完整性和稳定性。

第二步:确定系统版本和调整系统参数的方法(200-400字)首先,确定你使用的是哪个Linux系统版本,因为不同版本的系统对应的参数设置方法可能会有所不同。

可通过以下命令查看:cat /etc/issueuname -a根据系统版本的不同,可以参考相应的文档或在线资源来了解如何调整系统参数。

通常,系统参数可以通过修改配置文件或使用sysctl命令来进行设置。

第三步:调整网络连接参数以优化系统性能(400-700字)1. 调整TCP连接参数TCP连接参数可以控制连接的创建、维持和关闭等行为。

其中一些关键的参数包括:- tcp_fin_timeout: 该参数定义了连接关闭后等待关闭操作完成的时间,默认值为60秒。

可以根据实际情况适当缩短这个时间,如设置为30秒,以减少连接的持续时间。

- tcp_syn_retries: 该参数定义了在连接建立过程中重试的次数,默认值为5次。

Kernel panic常见原因

Kernel panic常见原因

kernel panic错误表现kernel panic 主要有以下几个出错提示:Kernel panic-not syncing fatal exception in interruptkernel panic - not syncing: Attempted to kill the idle task!kernel panic - not syncing: killing interrupt handler!Kernel Panic - not syncing:Attempted to kill init !kernel错误分析查看了一下 linux的源码文件,找到相关位置kernel/panic.cNORET_TYPE void panic(const char * fmt, ...){static char buf[1024];va_list args;bust_spinlocks(1);va_start(args, fmt);vsnprintf(buf, sizeof(buf), fmt, args);va_end(args);printk(KERN_EMERG "Kernel panic - not syncing: %s/n",buf);bust_spinlocks(0);kernel/exit.cif (unlikely(in_interrupt()))panic("Aiee, killing interrupt handler!"); #中断处理if (unlikely(!tsk->pid))panic("Attempted to kill the idle task!"); #空任务if (unlikely(tsk->pid == 1))panic("Attempted to kill init!"); #初始化从其他源文件和相关文档看到应该有几种原因:1、硬件问题使用了 SCSI-device 并且使用了未知命令#WDIOS_TEMPPANIC Kernel panic on temperature trip## The SETOPTIONS call can be used to enable and disable the card# and to ask the driver to call panic if the system overheats.## If one uses a SCSI-device of unsupported type/commands, one# immediately runs into a kernel-panic caused by Command Error. To better # understand which SCSI-command caused the problem, I extended this# specific panic-message slightly.##read/write causes a command error from# the subsystem and this causes kernel-panic2、系统过热如果系统过热会调用panci,系统挂起#WDIOS_TEMPPANIC Kernel panic on temperature trip## The SETOPTIONS call can be used to enable and disable the card# and to ask the driver to call panic if the system overheats.3、文件系统引起#A variety of panics and hangs with /tmp on a reiserfs filesystem#Any other panic, hang, or strange behavior## It turns out that there's a limit of six environment variables on the# kernel command line. When that limit is reached or exceeded, argument # processing stops, which means that the 'root=' argument that UML# usually adds is not seen. So, the filesystem has no idea what the# root device is, so it panics.# The fix is to put less stuff on the command line. Glomming all your# setup variables into one is probably the best way to go.Linux内核命令行有6个环境变量。

linux sigill代码

linux sigill代码

linux sigill代码1.引言1.1 概述Linux操作系统是一种广泛使用的开源操作系统,它具有强大的性能和灵活的设计。

在Linux操作系统中,SIGILL是一个重要的代码,它代表着非法指令(illegal instruction)的意思。

SIGILL代码对于理解和分析程序的运行过程具有重要意义。

当程序执行到一个非法指令时,操作系统会发送一个SIGILL信号给程序,以通知它出现了错误。

这个信号的处理可以由程序自行定义,通常情况下,程序会终止执行并报告错误。

SIGILL代码的含义是非常灵活的。

它可以用于检测代码中的错误、优化代码执行效率,或者实现一些特定的功能。

通过对SIGILL代码的分析,我们可以发现程序中潜在的问题或者优化的空间,从而提升程序的性能和稳定性。

然而,SIGILL代码也存在一定的局限性。

首先,由于它是在程序运行过程中触发的,因此对程序的性能会有一定的影响。

其次,在某些情况下,由于代码中使用了一些特殊的指令或者不可执行的操作,导致程序产生了非法指令的情况,这可能会误判为程序存在问题。

因此,在使用SIGILL 代码时,需要谨慎处理,并结合其他方法进行综合分析。

总之,SIGILL代码在Linux操作系统中具有重要的作用。

通过对SIGILL 代码的深入理解和应用,我们可以更好地开发和优化程序,提升系统的性能和稳定性。

在本文接下来的章节中,我们将详细介绍Linux操作系统以及SIGILL代码的含义和应用。

1.2文章结构文章结构部分的内容可以包括以下内容:在本文中,将会按照以下结构展开对Linux SIGILL代码的探讨:2.正文:2.1 Linux操作系统简介:本节将从Linux操作系统的发展历程、基本特性等方面进行介绍,以帮助读者对Linux操作系统有一个基本的了解。

2.2 SIGILL代码的含义:本节将着重探讨SIGILL代码的含义及其在Linux操作系统中的作用。

将会介绍SIGILL代码的定义、产生方式以及它在操作系统中的具体应用场景。

linux 设备异常oops排查思路 -回复

linux 设备异常oops排查思路 -回复

linux 设备异常oops排查思路-回复Linux设备异常oops排查思路在使用Linux系统时,偶尔会遇到设备异常oops(out-of-place)问题,这可能导致系统崩溃或无法正常工作。

为了解决这类问题,本文将提供一种逐步排查和解决设备异常oops的思路。

操作系统为Linux,以中括号内的内容为主题,将一步一步回答。

1. 异常oops是什么?异常oops是指Linux内核在出现问题时产生的一个信息记录,这个记录包含了导致系统崩溃或异常的原因。

oops通常会显示在终端或者/var/log/messages文件中,它提供了一些关键信息,例如错误代码、内核堆栈跟踪、内存使用情况等,帮助我们找到问题的根本原因。

2. 设置oops记录在处理设备异常oops问题之前,我们需要确保系统已经设置正确的oops记录。

编辑/etc/sysctl.conf文件,添加以下行,保存并重新加载sysctl:kernel.panic=1kernel.panic_on_oops=1这将使系统在oops或系统崩溃发生时立即崩溃,并记录相关信息。

3. 检查祝设备首先,我们需要检查设备是否存在硬件故障。

检查设备的物理连接是否良好,查看设备的运行状态和指示灯,以确认设备的正常工作。

如果可能的话,可以尝试将设备连接到另一台机器上,查看是否出现相同的问题。

如果设备工作正常,我们可以将问题归因于操作系统或驱动程序。

4. 分析oops日志当系统崩溃或出现oops时,内核会将相关信息记录到/var/log/messages文件中。

我们可以使用以下命令查看最新的oops日志:dmesg grep -i oops这将显示最近的oops日志。

根据这些信息,我们可以了解到内核遇到的问题、错误代码和堆栈跟踪信息等。

需要注意的是,有些oops日志可能会截断,只显示部分信息。

在此情况下,我们需要查看其他相关的日志文件,包括/var/log/syslog、/var/log/kern.log等。

Linux系统错误码对照表

Linux系统错误码对照表

Linux系统错误码对照表C Name Value DescriptionEPERM1Operation not permittedENOENT2No such file or directoryESRCH3No such processEINTR4Interrupted system callEIO5I/O errorENXIO6No such device or addressE2BIG7Arg list too longENOEXEC8Exec format errorEBADF9Bad file numberECHILD10No child processesEAGAIN11Try againENOMEM12Out of memoryEACCES13Permission deniedEFAULT14Bad addressENOTBLK15Block device requiredEBUSY16Device or resource busyEEXIST17File existsEXDEV18Cross-device linkENODEV19No such deviceENOTDIR20Not a directoryEISDIR21Is a directoryEINVAL22Invalid argumentENFILE23File table overflowEMFILE24Too many open filesENOTTY25Not a tty deviceETXTBSY26Text file busyEFBIG27File too largeENOSPC28No space left on deviceESPIPE29Illegal seekEROFS30Read-only file systemEMLINK31Too many linksEPIPE32Broken pipeEDOM33Math argument out of domainERANGE34Math result not representableEDEADLK35Resource deadlock would occurENAMETOOLONG36Filename too longENOLCK37No record locks availableENOSYS38Function not implementedENOTEMPTY39Directory not emptyELOOP40Too many symbolic links encounteredEWOULDBLOCK41Same as EAGAINENOMSG42No message of desired typeEIDRM43Identifier removedECHRNG44Channel number out of rangeEL2NSYNC45Level 2 not synchronizedEL3HLT46Level 3 haltedEL3RST47Level 3 resetELNRNG48Link number out of rangeEUNATCH49Protocol driver not attachedENOCSI50No CSI structure availableEL2HLT51Level 2 haltedEBADE52Invalid exchangeEBADR53Invalid request descriptorEXFULL54Exchange fullEXFULL54Exchange fullENOANO55No anodeEBADRQC56Invalid request codeEBADSLT57Invalid slotEDEADLOCK -Same as EDEADLKEBFONT59Bad font file formatENOSTR60Device not a streamENODATA61No data availableETIME62Timer expiredENOSR63Out of streams resourcesENONET64Machine is not on the network ENOPKG65Package not installedEREMOTE66Object is remoteENOLINK67Link has been severedEADV68Advertise errorESRMNT69Srmount errorECOMM70Communication error on send EPROTO71Protocol errorEMULTIHOP72Multihop attemptedEDOTDOT73RFS specific errorEBADMSG74Not a data messageEOVERFLOW75Value too large for defined data type ENOTUNIQ76Name not unique on networkEBADFD77File descriptor in bad state EREMCHG78Remote address changedELIBACC79Cannot access a needed shared library ELIBBAD80Accessing a corrupted shared library ELIBSCN81 A .lib section in an .out is corrupted ELIBMAX82Linking in too many shared libraries ELIBEXEC83Cannot exec a shared library directly EILSEQ84Illegal byte sequenceERESTART85Interrupted system call should be restarted ESTRPIPE86Streams pipe errorEUSERS87Too many usersENOTSOCK88Socket operation on non-socket EDESTADDRREQ89Destination address required EMSGSIZE90Message too longEPROTOTYPE91Protocol wrong type for socket ENOPROTOOPT92Protocol not available EPROTONOSUPPORT93Protocol not supported ESOCKTNOSUPPORT94Socket type not supported EOPNOTSUPP95Operation not supported on transport EPFNOSUPPORT96Protocol family not supported EAFNOSUPPORT97Address family not supported by protocol EADDRINUSE98Address already in use EADDRNOTAVAIL99Cannot assign requested address ENETDOWN100Network is downENETUNREACH101Network is unreachableENETRESET102Network dropped ECONNABORTED103Software caused connection ECONNRESET104Connection reset byENOBUFS105No buffer space availableEISCONN106Transport endpointENOTCONN107Transport endpointESHUTDOWN108Cannot send after transport ETOOMANYREFS109Too many referencesETIMEDOUT110Connection timed ECONNREFUSED111Connection refusedECONNREFUSED111Connection refused EHOSTDOWN112Host is down EHOSTUNREACH113No route to host EALREADY114Operation already EINPROGRESS115Operation now in ESTALE116Stale NFS file handle EUCLEAN117Structure needs cleaning ENOTNAM118Not a XENIX-named ENAVAIL119No XENIX semaphores EISNAM120Is a named type file EREMOTEIO121Remote I/O error EDQUOT122Quota exceeded ENOMEDIUM123No medium found EMEDIUMTYPE124Wrong medium type。

Linux中socket错误编码表errno

Linux中socket错误编码表errno

Linux中socket错误编码表errno最近在网络编程使用的过程中,发现errno会经常使用。

因此决定在此做个留用,以备以后使用。

虽然errno是非线程安全的,但是可以通过几种机制保证其安全。

最近在使用的过程中获得了errno,程序无法执行,也不知道如何解决问题。

因此,理解每一个返回的errno整数值的含义是很重要的。

这个我们可以通过strerror函数来实现。

strerror(返回整数errno对应的错误原因的描述字符串)所需头文件: #include<string.h>函数声明: char * strerror(int errnum);输入:整数errno输出:返回描述错误原因的字符串指针功能:用来依参数errnum 的错误代码来查询其错误原因的描述字符串,然后将该字符串指针返回。

示例:#include <string.h>#include <stdio.h>#define NUM 150int main(void){int i;for ( i=0; i<NUM; i++ ){printf( "%d:%s\n", i, strerror(i) );}return 0;}运行结果: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 unavailable 12: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 system 24:Too many open files25:Inappropriate ioctl for device 26: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 domain 34:Numerical result out of range 35:Resource deadlock avoided36:File name too long37:No locks available38:Function not implemented39:Directory not empty40:Too many levels of symbolic links 41:Unknown error 4142:No message of desired type43:Identifier removed44:Channel number out of range 45: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 libraries 83:Cannot exec a shared library directly84:Invalid or incomplete multibyte or wide character 85:Interrupted system call should be restarted 86: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 connected 107:Transport endpoint is not connected108:Cannot send after transport endpoint shutdown 109: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 file 119:No XENIX semaphores available 120:Is a named type file121:Remote I/O error122:Disk quota exceeded123:No medium found124:Wrong medium type125:Operation canceled126:Required key not available 127:Key has expired128:Key has been revoked129:Key was rejected by service 130:Owner died131:State not recoverable132:Unknown error 132133:Unknown error 133134:Unknown error 134135:Unknown error 135136:Unknown error 136137:Unknown error 137138:Unknown error 138139:Unknown error 139140:Unknown error 140141:Unknown error 141142:Unknown error 142143:Unknown error 143144:Unknown error 144145:Unknown error 145146:Unknown error 146147:Unknown error 147148:Unknown error 148149:Unknown error 149通过这个我们终于理解errno的含义了。

Linux下的段错误(Segmentation fault)产生的原因及调试方法(经典)

Linux下的段错误(Segmentation fault)产生的原因及调试方法(经典)

Linux下的段错误(Segmentation fault)产生的原因及调试方法(经典)2009-04-05 11:25简而言之,产生段错误就是访问了错误的内存段,一般是你没有权限,或者根本就不存在对应的物理内存,尤其常见的是访问0地址.一般来说,段错误就是指访问的内存超出了系统所给这个程序的内存空间,通常这个值是由gdtr来保存的,他是一个48位的寄存器,其中的32位是保存由它指向的gdt表,后13位保存相应于gdt的下标,最后3位包括了程序是否在内存中以及程序的在cpu中的运行级别,指向的gdt是由以64位为一个单位的表,在这张表中就保存着程序运行的代码段以及数据段的起始地址以及与此相应的段限和页面交换还有程序运行级别还有内存粒度等等的信息。

一旦一个程序发生了越界访问,cpu就会产生相应的异常保护,于是segmentation fault就出现了.在编程中以下几类做法容易导致段错误,基本是是错误地使用指针引起的1)访问系统数据区,尤其是往系统保护的内存地址写数据最常见就是给一个指针以0地址2)内存越界(数组越界,变量类型不一致等) 访问到不属于你的内存区域解决方法我们在用C/C++语言写程序的时侯,内存管理的绝大部分工作都是需要我们来做的。

实际上,内存管理是一个比较繁琐的工作,无论你多高明,经验多丰富,难免会在此处犯些小错误,而通常这些错误又是那么的浅显而易于消除。

但是手工“除虫”(debug),往往是效率低下且让人厌烦的,本文将就"段错误"这个内存访问越界的错误谈谈如何快速定位这些"段错误"的语句。

下面将就以下的一个存在段错误的程序介绍几种调试方法:1 dummy_function (void)2 {3 unsigned char *ptr = 0x00;4 *ptr = 0x00;5 }67 int main (void)8 {9 dummy_function ();1011 return 0;12 }作为一个熟练的C/C++程序员,以上代码的bug应该是很清楚的,因为它尝试操作地址为0的内存区域,而这个内存区域通常是不可访问的禁区,当然就会出错了。

Linux错误码大全(建议收藏)

Linux错误码大全(建议收藏)

Linux错误码大全查看错误代码errno是调试程序的一个重要方法。

当linuc C api函数发生异常时,一般会将errno变量(需include errno.h)赋一个整数值,不同的值表示不同的含义,可以通过查看该值推测出错的原因。

在实际编程中用这一招解决了不少原本看来莫名其妙的问题。

比较麻烦的是每次都要去linux源代码里面查找错误代码的含义,现在把它贴出来,以后需要查时就来这里看了。

1-34号错误号是在内核源码的include/asm-generic/errno-base.h定义35-132则是在include/asm-generic/errno.h中定义剩下还有一些更大的错误号是留给内核级别的,如系统调用等,用户程序一般是看不见的这些号的,Ubuntu9.10中/usr/src/linux-headers-2.6.31-21-generic/include/linux/errno.h#ifndef _ASM_GENERIC_ERRNO_BASE_H#define _ASM_GENERIC_ERRNO_BASE_H#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 10 /*No child processes */ #define EAGAIN 11 /*Try again */#define ENOMEM 12 /*Out of memory */#define EACCES 13 /*Permission denied */ #define EFAULT 14 /*Bad address */#define ENOTBLK 15 /*Block device required */ #define EBUSY16 /*Device or resource busy */ #define EEXIST 17 /*File exists */#define EXDEV 18 /*Cross-device link */#define ENODEV 19 /*No such device */#define ENOTDIR 20 /*Not a directory */#define EISDIR 21 /*Is a directory */#define EINVAL 22 /*Invalid argument */#define ENFILE 23 /*File table overflow */#define EMFILE 24 /*Too many open files */#define ENOTTY 25 /*Not a typewriter */#define ETXTBSY 26 /*Text file busy */#define EFBIG 27 /*File too large */#define ENOSPC 28 /*No space left on device */ #define ESPIPE 29 /*Illegal seek */#define EROFS 30 /*Read-only file system */#define EMLINK 31 /*Too many links */#define EPIPE 32 /*Broken pipe */#define EDOM 33 /*Math argument out of domain of func */#define ERANGE 34 /*Math result not representable */#endif#include#define EDEADLK 35 /*Resource deadlock would occur */ #define ENAMETOOLONG 36 /*File name too long */#define ENOLCK 37 /*No record locks available */ #define ENOSYS 38 /*Function not implemented */ #defineENOTEMPTY 39 /*Directory not empty */#define ELOOP 40 /*Too many symbolic links encountered */#define EWOULDBLOCK EAGAIN /*Operation would block */ #define ENOMSG 42 /*No message of desired type */ #define EIDRM 43 /*Identifier removed */#define ECHRNG 44 /*Channel number out of range */ #define EL2NSYNC 45 /*Level 2 not synchronized */ #define EL3HLT 46 /*Level 3 halted */#define EL3RST 47 /*Level 3 reset */#define ELNRNG 48 /*Link number out of range */#define EUNATCH 49 /*Protocol driver not attached */ #define ENOCSI 50 /*No CSI structure available */ #define EL2HLT 51 /*Level 2 halted */#define EBADE 52 /*Invalid exchange */#define EBADR 53 /*Invalid request descriptor */ #define EXFULL 54 /*Exchange full */#define ENOANO 55 /*No anode */#define EBADRQC 56 /*Invalid request code */ #define EBADSLT 57 /*Invalid slot */#define EDEADLOCK EDEADLK#define EBFONT 59 /*Bad font file format */#define ENOSTR 60 /*Device not a stream */#define ENODATA 61 /*No data available */#define ETIME 62 /*Timer expired */#define ENOSR 63 /*Out of streams resources */#define ENONET 64 /*Machine is not on the network */ #define ENOPKG 65 /*Package not installed */ #define EREMOTE 66 /*Object is remote */#define ENOLINK 67 /*Link has been severed */ #define EADV 68 /*Advertise error */#define ESRMNT 69 /*Srmount error */#define ECOMM 70 /*Communication error on send */ #define EPROTO 71 /*Protocol error */#define EMULTIHOP 72 /*Multihop attempted */#define EDOTDOT 73 /*RFS specific error */#define EBADMSG 74 /*Not a data message */#define EOVERFLOW 75 /*Value too large for defined data type */#define ENOTUNIQ 76 /*Name not unique on network */#define EBADFD 77 /*File descriptor in bad state */ #define EREMCHG 78 /*Remote address changed */ #define ELIBACC 79 /*Can not access a needed shared library */#define ELIBBAD 80 /*Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */#define ELIBMAX 82 /*Attempting to link in too many shared libraries */#define ELIBEXEC 83 /*Cannot exec a shared library directly */ #define EILSEQ 84 /*Illegal byte sequence */#define ERESTART 85 /*Interrupted system call should be restarted */#define ESTRPIPE 86 /*Streams pipe error */#define EUSERS 87 /*Too many users */#define ENOTSOCK 88 /*Socket operation on non-socket */#define EDESTADDRREQ 89 /*Destination address required */ #define EMSGSIZE 90 /*Message too long */#define EPROTOTYPE 91 /*Protocol wrong type for socket */ #define ENOPROTOOPT 92 /*Protocol not available */#define EPROTONOSUPPORT 93 /*Protocol not supported */ #define ESOCKTNOSUPPORT 94 /*Socket type not supported */ #define EOPNOTSUPP 95 /*Operation not supported on transport endpoint */#define EPFNOSUPPORT 96 /*Protocol family not supported */ #define EAFNOSUPPORT 97 /*Address family not supported by protocol */#define EADDRINUSE 98 /*Address already in use */#define EADDRNOTAVAIL 99 /*Cannot assign requested address */#define ENETDOWN 100 /*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 105 /*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 /*T oo many references: cannot splice */#define ETIMEDOUT 110 /*Connection timed out */#define ECONNREFUSED 111 /*Connection refused */ #define EHOSTDOWN 112 /*Host is down */#define EHOSTUNREACH 113 /*No route to host */#define EALREADY 114 /*Operation already in progress */ #define EINPROGRESS 115 /*Operation now in progress */ #define ESTALE 116 /*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 120 /*Is a named type file */ #define EREMOTEIO 121 /*Remote I/O error */#define EDQUOT 122 /*Quota exceeded */#define ENOMEDIUM 123 /*No medium found */#define EMEDIUMTYPE 124 /*Wrong medium type *#define ECANCELED 125 / *操作已取消*/#define ENOKEY 126 / *必需的密钥不可用*/ #define EKEYEXPIRED 127 / *密钥已过期*/#define EKEYREVOKED 128 / *密钥已被撤销*/#define EKEYREJECTED 129 / *密钥被服务拒绝*// *用于强大的互斥体*/#define EOWNERDEAD 130 / *所有者死亡*/#define ENOTRECOVERABLE 131 / *状态不可恢复*/#define ERFKILL 132 / *由于射频杀死*/#ifdef __KERNEL__/ **用户程序切勿看到这些内容。

linux_c_write失败后的处理方式_概述及解释说明

linux_c_write失败后的处理方式_概述及解释说明

linux c write失败后的处理方式概述及解释说明1. 引言1.1 概述在Linux C编程中,write函数是一种常用的系统调用,用于向文件描述符写入数据。

然而,在实际使用过程中,我们经常会遇到write函数写入失败的情况,这可能导致数据丢失或应用程序异常终止。

因此,正确处理write函数的失败情况至关重要。

本文将概述Linux C中write函数失败后的处理方式,并详细解释各种解决方案的原理和应用场景。

通过了解不同的处理机制,读者将能够正确应对write函数写入失败的情况,从而提高程序的稳定性和可靠性。

1.2 文章结构本文包含以下几个部分内容:- 引言:介绍文章的主题和目标。

- 正文:详细讨论Linux C中的write函数、其返回值及失败可能原因。

- 解决方案一:错误码处理机制:介绍如何利用错误码来处理write函数的失败情况,并提供具体应用时的实例。

- 解决方案二:重试机制和回滚策略:探讨如何通过实现重试机制和回滚策略来应对write函数写入失败带来的问题,并给出示例代码。

- 结论:总结讨论结果并提出建议,强调正确处理write函数失败带来的影响。

通过本文的阅读,读者将对Linux C中write函数失败后的处理方式有一个全面和清晰的理解。

1.3 目的本文的目的是回答以下问题:- write函数在Linux C编程中的作用及常见用法。

- write函数返回值代表什么含义,如何判断写入是否成功。

- 导致write函数失败的可能原因有哪些。

- 如何在应用程序中正确地处理write函数写入失败的情况。

- 错误码处理机制、重试机制和回滚策略分别是如何应对write函数写入失败问题的。

通过深入了解这些内容,读者将能够在实际项目开发中更好地处理write函数写入失败,并提升编程技巧。

2. 正文:2.1 Linux C中的write函数write函数是Linux C编程中常用的一个系统调用函数,用于向文件描述符(file descriptor)写入数据。

linux cp copy失败的后返回的值 -回复

linux cp copy失败的后返回的值 -回复

linux cp copy失败的后返回的值-回复Linux cp copy命令是用来复制文件或目录的常用命令。

然而,有时候我们会遇到copy失败的情况,此时命令会返回一个特定的值,以表示复制过程中发生了什么错误。

本篇文章将分步回答有关copy失败后返回的值的问题,并深入探讨每个返回值代表的含义。

第一部分:理解cp命令返回值在Linux中,大部分命令都会返回一个称为"退出状态码"的值,它代表了命令的执行结果。

对于cp命令而言,以下是它可能返回的一些常见退出状态码:1. 0(成功):代表复制过程顺利完成。

2. 1(失败):代表发生了未知错误,导致复制失败。

3. 2(参数错误):代表输入的参数格式不正确,例如路径错误或不存在的源文件。

4. 3(文件权限错误):代表您没有足够的权限复制文件。

5. 4(文件打开错误):代表系统无法打开源文件。

6. 5(目录错误):代表目标目录不存在或无法访问。

第二部分:解读每个返回值的含义现在,我们将对每个返回值进行详细解释,并讨论可能导致这些错误的原因。

1. 0(成功):这是最理想的结果,代表复制成功完成。

如果您收到这个返回值,那么复制过程就顺利完成了。

2. 1(失败):这个返回值代表着某些未知的错误发生了,导致复制失败。

这可能是由于磁盘空间不足、文件系统错误或其他不可预知的问题导致的。

在这种情况下,您可能需要检查文件系统状态、查看系统日志或尝试使用不同的复制方法来解决问题。

3. 2(参数错误):如果您输入的源文件路径或目标路径有误,或者要复制的文件不存在,那么cp命令会返回2。

请确保正确指定了源文件和目标路径,并且它们都是存在的,以避免这种错误。

4. 3(文件权限错误):如果当前用户没有足够的权限复制文件,那么cp 命令会返回3。

在这种情况下,您可以尝试使用sudo命令以超级用户权限执行复制操作,或者联系系统管理员以获取所需的权限。

5. 4(文件打开错误):这个返回值表示cp命令无法打开源文件,可能是因为文件被其他进程锁住或者被损坏。

linux 高压力 connection reset by peer 系统参数 -回复

linux 高压力 connection reset by peer 系统参数 -回复

linux 高压力connection reset by peer 系统参数-回复文章标题:解析Linux高压力下出现的“connection reset by peer”错误及相关系统参数调整导语:在Linux服务器的高压力环境下,经常会出现一些网络错误,其中最常见的是“connection reset by peer”错误。

这个错误的出现往往会导致网络连接的中断,影响服务的稳定性和可靠性。

本文将详细介绍这个错误的原因以及如何通过系统参数调整来解决该问题。

第一部分:错误原因的分析在理解和修复“connection reset by peer”错误之前,我们首先需要了解该错误产生的原因。

简而言之,当一个连接在正常通信过程中突然被对方终止时,就会出现这个错误。

这种情况通常是由以下几个原因引起的:1. 网络超时:当网络连接超过设定的时间阈值,连接会被服务器或客户端主动关闭,以防止连接资源的浪费。

这种情况下,服务器会向对方发送一个“FIN”标志来关闭连接,并在异常终止后错误地中断通信。

2. 连接过载:当服务器同时处理大量连接请求时,超过了其负载能力,会导致连接的异常终止。

这可能是由于CPU或内存的负载过高,或者网络带宽限制引起的。

3. 应用程序错误:在某些情况下,应用程序本身的错误可能导致连接意外终止。

这可能是由于应用程序的代码编写错误、内存泄漏、资源管理错误或其他潜在问题引起的。

第二部分:系统参数调整有了对错误原因的了解,下面我们将介绍一些可以通过调整系统参数来解决“connection reset by peer”错误的方法。

1. 调整TCP相关参数:- 增加连接超时时间:通过修改tcp_keepalive_time参数来增加连接超时时间,可以减少连接因为超时而被关闭的可能性。

可以使用以下命令进行修改:`sysctl -w net.ipv4.tcp_keepalive_time=<value>`- 增加连接内存和缓冲区:通过增加系统的TCP连接内存和缓冲区大小,可以提高系统处理连接请求的能力。

fat中的f_mkdir的用法

fat中的f_mkdir的用法

fat中的f_mkdir的用法在Linux系统中,我们经常会用到文件操作命令来管理文件和目录。

其中一个非常常用的命令是`mkdir`,用于创建目录。

而`f_mkdir`则是fat文件系统中用于创建目录的函数。

在本文中,我们将探讨`f_mkdir`在fat文件系统中的使用方法。

## 1. 简介fat文件系统(File Allocation Table)是一种常用的文件系统,广泛应用于各种存储设备上,如硬盘、U盘、SD卡等。

`f_mkdir`是fat文件系统中的一个函数,用于在指定的目录下创建一个新的子目录。

## 2. 使用方法在使用`f_mkdir`函数之前,我们需要先了解其语法和参数。

以下是`f_mkdir`函数的语法:```FRESULT f_mkdir (const TCHAR* path /* Directory path */);````f_mkdir`函数只有一个参数`path`,表示要创建的新目录的路径。

该参数是一个字符串类型(TCHAR),以null结尾,可以使用相对路径或绝对路径。

下面是一个示例代码,演示了如何使用`f_mkdir`函数在当前目录下创建一个名为"new_dir"的新目录:```c#include <stdio.h>#include <stdlib.h>#include "ff.h"int main() {FRESULT res;char path[] = "new_dir";// 创建目录res = f_mkdir(path);if (res != FR_OK) {printf("创建目录失败!错误码:%d\n", res);return 1;}printf("目录创建成功!\n");return 0;}```在上述示例中,我们首先包含了相关的头文件`stdio.h`、`stdlib.h`和`ff.h`,以便使用`f_mkdir`函数。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

常见的Linux系统错误码,即errorno的值1 EPERM Operation not permitted 操作不许可2 ENOENT No such file or directory 无此文件或目录3 ESRCH No such process 无此过程4 EINTR Interrupted system call 系统调用被禁止5 EIO I/O error I/O 错误6 ENXIO No such device or address 无此器件或地址7 E2BIG Arg list too long Arg 列表太长8 ENOEXEC Exec format error Exec 格式错误9 EBADF Bad file number 文件数目错误10 ECHILD No child processes 无子过程11 EAGAIN Try again 再试一遍12 ENOMEM Out of memory 内存溢出13 EACCES Permission denied 许可拒绝14 EFAULT Bad address 错误的地址15 ENOTBLK Block device required 需要块设备16 EBUSY Device or resource busy 设备或资源忙17 EEXIST File exists 文件存在18 EXDEV Cross-device link 跨器链接19 ENODEV No such device 无此设备20 ENOTDIR Not a directory 不是一个目录21 EISDIR Is a directory 是一个目录22 EINV AL Invalid argument 无效的函数自变量23 ENFILE File table overflow 文件表溢出24 EMFILE Too many open files 打开的文件太多25 ENOTTY Inappropriate ioctl for device26 ETXTBSY Text file busy 文本文件忙27 EFBIG File too large 文件太大28 ENOSPC No space left on device 磁盘空间不足29 ESPIPE Illegal seek 不合法的寻找30 EROFS Read-only file system 只读文件系统31 EMLINK Too many links 太多的链接/usr/include/asm-generic/errno-base.h#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 10 /* No child processes */#define EAGAIN 11 /* Try again */#define ENOMEM 12 /* Out of memory */#define EACCES 13 /* Permission denied */#define EFAULT 14 /* Bad address */#define ENOTBLK 15 /* Block device required */#define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */#define EXDEV 18 /* Cross-device link */#define ENODEV 19 /* No such device */#define ENOTDIR 20 /* Not a directory */#define EISDIR 21 /* Is a directory */#define EINVAL 22 /* Invalid argument */#define ENFILE 23 /* File table overflow */#define EMFILE 24 /* Too many open files */#define ENOTTY 25 /* Not a typewriter */#define ETXTBSY 26 /* Text file busy */#define EFBIG 27 /* File too large */#define ENOSPC 28 /* No space left on device */#define ESPIPE 29 /* Illegal seek */#define EROFS 30 /* Read-only file system */#define EMLINK 31 /* Too many links */#define EPIPE 32 /* Broken pipe */#define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable *//usr/include/asm-generic/errno.h#define EDEADLK 35 /* Resource deadlock would occur */#define ENAMETOOLONG 36 /* File name too long */#define ENOLCK 37 /* No record locks available */#define ENOSYS 38 /* Function not implemented */#define ENOTEMPTY 39 /* Directory not empty */#define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */#define ENOMSG 42 /* No message of desired type */#define EIDRM 43 /* Identifier removed */#define ECHRNG 44 /* Channel number out of range */#define EL2NSYNC 45 /* Level 2 not synchronized */#define EL3HLT 46 /* Level 3 halted */#define EL3RST 47 /* Level 3 reset */#define ELNRNG 48 /* Link number out of range */#define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */#define EL2HLT 51 /* Level 2 halted */#define EBADE 52 /* Invalid exchange */#define EBADR 53 /* Invalid request descriptor */#define EXFULL 54 /* Exchange full */#define ENOANO 55 /* No anode */#define EBADRQC 56 /* Invalid request code */#define EBADSLT 57 /* Invalid slot */#define EDEADLOCK EDEADLK#define EBFONT 59 /* Bad font file format */#define ENOSTR 60 /* Device not a stream */#define ENODATA 61 /* No data available */#define ETIME 62 /* Timer expired */#define ENOSR 63 /* Out of streams resources */#define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */#define EREMOTE 66 /* Object is remote */#define ENOLINK 67 /* Link has been severed */#define EADV 68 /* Advertise error */#define ESRMNT 69 /* Srmount error */#define ECOMM 70 /* Communication error on send */#define EPROTO 71 /* Protocol error */#define EMULTIHOP 72 /* Multihop attempted */#define EDOTDOT 73 /* RFS specific error */#define EBADMSG 74 /* Not a data message */#define EOVERFLOW 75 /* Value too large for defined data type */#define ENOTUNIQ 76 /* Name not unique on network */#define EBADFD 77 /* File descriptor in bad state */#define EREMCHG 78 /* Remote address changed */#define ELIBACC 79 /* Can not access a needed shared library */#define ELIBBAD 80 /* Accessing a corrupted shared library */#define ELIBSCN 81 /* .lib section in a.out corrupted */#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */#define EILSEQ 84 /* Illegal byte sequence */#define ERESTART 85 /* Interrupted system call should be restarted */#define ESTRPIPE 86 /* Streams pipe error */#define EUSERS 87 /* Too many users */#define ENOTSOCK 88 /* Socket operation on non-socket */#define EDESTADDRREQ 89 /* Destination address required */#define EMSGSIZE 90 /* Message too long */#define EPROTOTYPE 91 /* Protocol wrong type for socket */#define ENOPROTOOPT 92 /* Protocol not available */#define EPROTONOSUPPORT 93 /* Protocol not supported */#define ESOCKTNOSUPPORT 94 /* Socket type not supported */#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */#define EPFNOSUPPORT 96 /* Protocol family not supported */#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */#define EADDRNOTAVAIL 99 /* Cannot assign requested address */#define ENETDOWN 100 /* 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 105 /* 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 110 /* Connection timed out */#define ECONNREFUSED 111 /* Connection refused */#define EHOSTDOWN 112 /* Host is down */#define EHOSTUNREACH 113 /* No route to host */#define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* 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 120 /* Is a named type file */#define EREMOTEIO 121 /* Remote I/O error */#define EDQUOT 122 /* Quota exceeded */#define ENOMEDIUM 123 /* No medium found */#define EMEDIUMTYPE 124 /* Wrong medium type */#define ECANCELED 125 /* Operation Canceled */#define ENOKEY 126 /* Required key not available */#define EKEYEXPIRED 127 /* Key has expired */#define EKEYREVOKED 128 /* Key has been revoked */#define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */#define EOWNERDEAD 130 /* Owner died */#define ENOTRECOVERABLE 131 /* State not recoverable */。

相关文档
最新文档