[英]Why does GDB break when writing to the network?
I get this error every time my program reaches a write()
function. 每次我的程序到达
write()
函数时,我都会收到此错误。 The program will continue again, but will stop on the next write()
call. 程序将再次继续,但将在下一次
write()
调用时停止。 When I run this program outside of gdb, it runs properly. 当我在gdb之外运行这个程序时,它运行正常。
Program received signal SIGPIPE, Broken pipe.
0x00007ffff794b340 in __write_nocancel () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
I've been told that this happens when the socket is closed from the remote end, but how would that be happening. 我被告知,当套接字从远端关闭时会发生这种情况,但是会发生什么。
Note: The server and client are both running on the same machine, and the server was prebuilt for me, so I don't have access to it's code. 注意:服务器和客户端都在同一台机器上运行,并且服务器是为我预先构建的,因此我无法访问它的代码。
SIGPIPE
is generated when the other side closed the connection. 当另一方关闭连接时生成
SIGPIPE
。 And there are good reasons for its existence. 它存在的原因很充分 。
By default gdb catches SIGPIPE
. 默认情况下,gdb捕获
SIGPIPE
。
If you aren't interested, and chances are you don't, simply disable it: 如果您不感兴趣,并且有可能不这样做,只需禁用它:
handle SIGPIPE nostop noprint pass
I've been told that this happens when the socket is closed from the remote end, but how would that be happening.
我被告知,当套接字从远端关闭时会发生这种情况,但是会发生什么。
You mean why? 你是说为什么? Since you don't have the source we can only guess.
由于你没有源,我们只能猜测。
Perhaps it already sent all the data it wanted and closed the connection, because there's no point keeping it open... Remember, connections can be half-closed (that is, from one side). 也许它已经发送了它想要的所有数据并关闭了连接,因为没有必要保持打开...记住,连接可以半封闭 (即从一侧)。 The server doesn't want to read any further, and just waits you to read the data and close your side.
服务器不想再读取任何内容,只是等待您阅读数据并关闭您的身边。 Probably nothing went wrong - but you have to decide that yourself, as only you know what the application protocol is.
可能没有出错 - 但你必须自己决定,因为只有你知道应用程序协议是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.