comm: ignore SIGPIPE
This prevents client and server from being sent a SIGPIPE (and terminating) when the other side unexpectedly closes the connection. It's way easier to handle this condition when checking the write() return value, than to do anything smart in a SIGPIPE handler. More details: <http://stackoverflow.com/questions/108183/how-to-prevent-sigpipes-or-handle-them-properly> Change-Id: I1da5bf5ef79c8b7b00ede976e96ed4f1c560049d
This commit is contained in:
@ -1,10 +1,18 @@
|
||||
#include <string>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "SocketComm.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
void SocketComm::init()
|
||||
{
|
||||
// It's usually much easier to handle the error on write(), than to do
|
||||
// anything intelligent in a SIGPIPE handler.
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
}
|
||||
|
||||
bool SocketComm::sendMsg(int sockfd, google::protobuf::Message& msg)
|
||||
{
|
||||
#ifdef USE_SIZE_PREFIX
|
||||
|
||||
Reference in New Issue
Block a user