简体   繁体   中英

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. (client os is ubuntu server 12.04 LTS)

I do the following test:

  1. After the 3 handshakes is finished. 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.

Why the bash don't print the "Broken pipe" log after process dead ?

But i start the process using the gdb, repeat the upper steps . the process dead ,and gdb show the following log:

"Program received signal SIGPIPE, Broken pipe."

If the client doesn't catch SIGPIPE, then it can't possibly print an error message! 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. Since your client is not handling SIGPIPE, it is not printing that error message, but just terminating. When you run within gdb, gdb is telling you that the child process terminated because of a SIGPIPE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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