遇到这两个错误时,需要继续循环读。 eagain还好理解点。 eintr 为啥需要继续读?遇到中断信号,进程都停掉了,为何还要循环读? ps,还有哪些错误需要继续循环读?
by zhendehaoren - C/C++ - 2014-07-24 15:29:12 阅读(2414) 回复(4)
最近 socket 读数据老是遇到 Interrupted system call (eintr),代码改为如下解决 while (1) { select(socket+1, &readfds, NULL, NULL, &tv); if (FD_ISSET(socket, &readfds)) { printf("connection got!\n"); break; } else{ if (errno == eintr) continue; else printf("Timed out.\n"); } } 下面的列表显示常见的 Linux 系统错误代码。 ...
最近 socket 读数据老是遇到 Interrupted system call (eintr),代码改为如下解决while (1){ select(socket+1, &readfds, NULL, NULL, &tv); if (FD_ISSET(socket, &readfds)) printf("connection got!\n"); else{ if (errno == eintr) continue; else printf("Timed out.\n"); }}下面的列表显示常见的 Linux 系统错误代码。 1 EPERMOperation not permitted操作不许可 2 ENOENTNo such file or director...
socket程序两台主机通信,建立连接后一端读取文件并发送,另一端接收并写入文件,如果文件稍微大了一点,接收端报eagain的错误,但是只要接受端不写文件的话就没有这个错误,是不是solaris对资源的使用有什么限制,有遇到这种问题吗?
socket程序两台主机通信,建立连接后一端读取文件并发送,另一端接收并写入文件,如果文件稍微大了一点,接收端报eagain的错误,但是只要接受端不写文件的话就没有这个错误,是不是solaris对资源的使用有什么限制,有遇到这种问题吗?
编译过程中出现错误
eintr 未声明
源代码如下:
#include
编译过程中出现错误
eintr 未声明
源代码如下:
#include
在fork出的N个子进程中使用消息队列接收数据,Socket发送数据,在某一个Socket第一次send成功后,此时消息队列会出现无法接收数据的情况,得到的代码是errno = eintr,msg = Interrupted system call!。但这种现象只会在子进程刚开始发数据的时候持续两到三次,以后不再产生!请教该问题可能产生的原因,是否需要屏蔽某信号?
这两天做测试,发现在高并发情况下,semop()操作经常会返回eagain(Resource temporarily unavailable)。 相关的手册对此的解释是: [RedHat Linux] eagain An operation could not proceed immediately and either IPC_NOWAIT was asserted in its sem_flg or the time limit specified in time-out expired. [UnixWare] The operation would result in suspension of the calling process but (sem_flg&IPC_NOWAIT) is true. ...
UNIX网络编程中有这样一个函数,实现读取n字节。 ssize_t readn( int fd, void *vptr, size_t n ) { size_t nleft; ssize_t nread; char *ptr; ptr=vptr; nleft=n; while( nleft>0 ) { if( (nread=read(fd, ptr, nleft))<0 ) { if( eintr==errno ) nread=0; //注意这里! else return -1; }//if else if( nread==0 ) break; nleft-=nread; ptr+=nread; }//while retu...
当select被信号中断时, 我们在程序中该怎么处理呢? 最近经常在程序的debug文件中看到类似的信息: 2008/11/20/9:4:28 pty.c(00581):main DEBUG: -- @" select: Interrupted system call (4)"@ 2008/11/20/9:4:28 pty.c(00581):main DEBUG: -- @" select: Interrupted system call (4)"@ 我在程序中默认的是操作是遇到errno是eintr, 就continue, 不知道这样做对不对呢?