如果你在读取一个管道、套接口、FIFO等设备时,当写入端关闭连接时,你将会得到一个文件结束符(EOF)(read()返回零字节读取)。 如果你试图向一个管道或套接口写入,当读取方关闭连接,你将得到一个sigpipe的信号,它会使进程终止除非指定处理方法。(如果你选择屏蔽或忽略信号,write()会以EPIPE错误退出。) ----------------------------------- 问题是: 读取的时候好处理,写...
程序为什么没有出现sigpipe呢?
[code]
#include
做了一个LINUX下的服务器程序,大致代码是 main() { sem_t procBlock; sem_init(&procBlock, 0, 0); struct sigaction act, oact; act.sa_handler = SIG_IGN; sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_flags |= SA_RESTART; if(sigaction(sigpipe, &act, &oact) < 0) { printf("disable::sigaction"); return 0; } ServerThread pThread...
我的系统是redhat-2.4.32,向一个对端未打开的FIFO进行写操作,不会引发sigpipe,但是man 4 fifo上面说这样做会引发sigpipe [code] NOTES When a process tries to write to a FIFO that is not opened for read on the other side, the process is sent a sigpipe signal. FIFO special files can be created by mkfifo(3), and are specially indi- cated in ls -l. SEE ALSO mkfifo(3), ...
#include
为什么程序只运行到bind时就失败了呢,运行显示是:socket ok bind UNknown error 哪位能给指点一下嘞!!! #!/usr/bin/perl # The server and the client are on the same machine. $AF_INET=1; # The domain is AF_INET $SOCK_STREAM=1; # The type is SOCK_STREAM $PROTOCOL=0; # Protocol 0 is accepted as the "correct ...