标签:log div har connect closed ogr lock 提示 cte
在调试cs时,s端循环收,c端循环发,s端意外崩溃后,c端自动退出,终端提示SIGPIPE导致c端退出。man 7 signal:
SIGPIPE 13 Term Broken pipe: write to pipe with no readers
SIGPIPE发生在:写一个没有读的管道,默认动作是终止程序。man 2 write:
EPIPE fd is connected to a pipe or socket whose reading end is closed. When this happens the writing process will also receive a SIG- PIPE signal. (Thus, the write return value is seen only if the program catches, blocks or ignores this signal.)
write的错误码EPIPE发生在写的fd对应的pipe或者socket对端的读端关闭了时。写操作的返回值仅当程序捕获,阻塞,忽略此信号时才能收到,因为SIGPIPE默认会终止程序。
有一个细节,使用gdb单步调试c端,在开始write前,手动终止s端,c端收到s的FIN分节,并回复ack,c端处于CLOSE_WAIT状态,此时,c端的write操作返回的数值是正常的,socket状态不存在了,wireshark抓包会发现一个RST包,表示socket连接已重置,再次write,将会立即收到SIGPIPE。准确的讲写一个已经收到RST分节的socket会产生SIGPIPE。
标签:log div har connect closed ogr lock 提示 cte
原文地址:http://www.cnblogs.com/thammer/p/7103065.html