When the client close closes the connection, if the server side then sends the data, according to the TCP protocol, the server side receives the RST response, when the server side sends the data to the client again, the system sends a SIGPIPE signal to the server process. Tell the server process that the peer connection is closed and no more data is being written. However, according to the default rules of the signal, the default processing action of the SIGPIPE signal is terminate (terminating), so the server process ends. This causes the server to shut down due to client side shutdown.
In commercial development, this situation cannot be allowed. The way to avoid this is to ignore the sigpipe signal by adding the phrase "signal (sigpipe,sig_ign)" to the code.
Program exit problems caused by Linux network programming-sigpipe signals