In the commissioning of CS, the S-end loop, the C-terminal loop, the S-end after an unexpected crash, the C-terminal automatic exit, terminal hint Sigpipe cause C end exit. Man 7 signal:
Sigpipe broken pipe:write to pipe with no readers
Sigpipe occurs when: Write a pipe that is not read, the default action is to terminate the program. Man 2 write:
Epipe is is closed. This happens the writing process would also receive a sig- PIPE signal. return is if the this signal.)
The write error code epipe occurs when the read end of the write FD corresponding pipe or socket pair end is closed. The return value of the write operation is only received when the program catches, blocks, and ignores this signal because sigpipe terminates the program by default.
There is a detail, using GDB single-step debugging C-side, before the start of write, manually terminate the S-side, C-side received the fin section of S, and reply to the ack,c end is in the close_wait state, at this time, the C end of the write operation returned the value is normal, the socket state does not exist, Wireshark Grab bag will find an RST package, indicating that the socket connection has been reset, write again, will receive the sigpipe immediately. The exact writing of a socket that has received the RST sub-section will produce sigpipe.
Signals to be aware of in Linux network programming sigpipe