简体   繁体   English

为什么bash在进程死后不打印“Broken pipe”日志?

[英]Why the bash doesn't print the “Broken pipe” log after process dead?

My client will loop send the package to server. 我的客户端将循环发送包到服务器。 the client program don't catch the SIGPIPE. 客户端程序没有捕获SIGPIPE。 (client os is ubuntu server 12.04 LTS) (客户端操作系统是ubuntu服务器12.04 LTS)

I do the following test: 我做了以下测试:

  1. After the 3 handshakes is finished. 3次握手完成后。 Then client will send some packages to server. 然后客户端将一些包发送到服务器。 server can receive the packages normal. 服务器可以正常收到包。

  2. Then i suddenly kill the server process. 然后我突然杀了服务器进程。

  3. The client process is dead. 客户流程已经死了。 But I don't see any log show "Broken pipe". 但我没有看到任何日志显示“断管”。

I think the bash will report the dead cause. 我认为bash将报告死因。

Why the bash don't print the "Broken pipe" log after process dead ? 为什么bash在进程死后不打印“Broken pipe”日志?

But i start the process using the gdb, repeat the upper steps . 但是我使用gdb启动进程,重复上面的步骤。 the process dead ,and gdb show the following log: 进程死了,gdb显示以下日志:

"Program received signal SIGPIPE, Broken pipe." “程序收到信号SIGPIPE,Broken pipe。”

If the client doesn't catch SIGPIPE, then it can't possibly print an error message! 如果客户端没有捕获SIGPIPE,那么它不可能打印错误消息! Messages of the form "Broken pipe" are printed by the program that receives the SIGPIPE in response to either a write error or as a response to the signal. 形式为“Broken pipe”的消息由接收SIGPIPE的程序打印,以响应写入错误或作为对信号的响应。 Since your client is not handling SIGPIPE, it is not printing that error message, but just terminating. 由于您的客户端不处理SIGPIPE,因此它不会打印该错误消息,而只是终止。 When you run within gdb, gdb is telling you that the child process terminated because of a SIGPIPE. 当您在gdb中运行时,gdb会告诉您子进程因SIGPIPE而终止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM