简体   繁体   English

为什么GDB在写入网络时会中断?

[英]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.

相关问题 当您执行“ break function-name”时,GDB如何确定要中断的地址? - How does GDB determine the address to break at when you do “break function-name”? 进入子进程时gdb中断 - gdb break when entering child process 为什么gdb将sqrt(3)评估为0? - Why does gdb evaluate sqrt(3) to 0? 当用户输入-0.1时,为什么这个循环不会立即中断 - Why does this loop not break immediately when the user inputs -0.1 为什么在启用-O2或更高版本时此代码会中断? - Why does this code break when -O2 or higher is enabled? 当我使用偏移量在某个地址处中断时,gdb会停止程序 - gdb stops program when I break at an address while it works with an offset 为什么多次执行时局部变量的地址会有所不同,但是在使用GDB进行调试时却没有? - Why does the address of a local variable vary when executing multiple times, but not when debugging it with GDB? Gdb条件正则表达式中断 - Gdb conditional regex break 为什么GDB在数组索引越界时显示正常退出状态? - Why does GDB shows the status exited normally when the array index is out of bounds? 交换二叉树节点时,为什么GDB监视点在不相关的行上停止? - Why does a GDB watchpoint stop on an irrelevant line when swapping binary tree nodes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM