From 52c0e3d3c6b8bb09d55c894cf477cb61c4845a29 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Fri, 24 May 2019 21:02:01 +0300 Subject: [PATCH] Catch unwanted signals in linux --- components/net/cpp/src/universe.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/net/cpp/src/universe.cpp b/components/net/cpp/src/universe.cpp index b78af3990..130d7ec41 100644 --- a/components/net/cpp/src/universe.cpp +++ b/components/net/cpp/src/universe.cpp @@ -6,6 +6,10 @@ #pragma comment(lib, "Rpcrt4.lib") #endif +#ifndef WIN32 +#include <signal.h> +#endif + using std::string; using std::vector; using std::thread; @@ -196,6 +200,9 @@ bool Universe::_subscribe(const std::string &res) { } void Universe::__start(Universe * u) { +#ifndef WIN32 + signal(SIGPIPE,SIG_IGN); +#endif // WIN32 u->_run(); } @@ -280,6 +287,7 @@ void Universe::_run() { } if (FD_ISSET(s->_socket(), &sfderror_)) { s->socketError(); + s->close(); } } else if (s != NULL) { // Erase it @@ -288,6 +296,7 @@ void Universe::_run() { if ((*i) == s) { LOG(INFO) << "REMOVING SOCKET"; peers_.erase(i); break; + // TODO Remove subscribers } } } -- GitLab