diff --git a/deps/evcom/evcom.c b/deps/evcom/evcom.c index 629864d58f..48220a6074 100644 --- a/deps/evcom/evcom.c +++ b/deps/evcom/evcom.c @@ -32,6 +32,8 @@ #include #include /* memset */ +#include + #include /* TCP_NODELAY */ #include #include /* shutdown */ @@ -135,6 +137,14 @@ evcom_buf_new (const char *base, size_t len) return buf; } +void evcom_ignore_sigpipe (void) +{ + struct sigaction sa; + bzero(&sa, sizeof(sa)); + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); +} + static int close_asap (evcom_descriptor *d) { diff --git a/deps/evcom/evcom.h b/deps/evcom/evcom.h index fae9244747..88056a9efb 100644 --- a/deps/evcom/evcom.h +++ b/deps/evcom/evcom.h @@ -159,6 +159,9 @@ typedef struct evcom_server { (*on_connection)(struct evcom_server *, struct sockaddr *remote_addr); } evcom_server; +/* Highly recommended to ignore SIGPIPE! */ +void evcom_ignore_sigpipe (void); + void evcom_reader_init (evcom_reader*); void evcom_reader_set (evcom_reader*, int fd); void evcom_reader_attach (EV_P_ evcom_reader*); diff --git a/deps/evcom/test/test.c b/deps/evcom/test/test.c index 7aadebeebc..0ce3370866 100644 --- a/deps/evcom/test/test.c +++ b/deps/evcom/test/test.c @@ -776,6 +776,8 @@ main (void) fprintf(stderr, "sizeof(evcom_reader): %d\n", (int)sizeof(evcom_reader)); fprintf(stderr, "sizeof(evcom_writer): %d\n", (int)sizeof(evcom_writer)); + evcom_ignore_sigpipe(); + #if EVCOM_HAVE_GNUTLS gnutls_global_init(); diff --git a/src/net.h b/src/net.h index 593cacd439..69442b2d38 100644 --- a/src/net.h +++ b/src/net.h @@ -95,10 +95,6 @@ private: connection->OnClose(); - if (s->errorno) { - printf("socket died: %s\n", strerror(s->errorno)); - } - assert(connection->attached_); connection->Detach(); diff --git a/src/node.cc b/src/node.cc index 05f3f1f4dc..7fbd6903fb 100644 --- a/src/node.cc +++ b/src/node.cc @@ -318,6 +318,7 @@ ParseArgs (int *argc, char **argv) int main (int argc, char *argv[]) { + evcom_ignore_sigpipe(); ev_default_loop(EVFLAG_AUTO); // initialize the default ev loop. // start eio thread pool