From a1ba08b7dbdba05ac6e24f1e1b8ef40003356636 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 23 Oct 2022 01:47:44 +0200 Subject: [PATCH] tools/hexnet: Shut down connections when gracefully handling signals --- src/tools/hexnet.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tools/hexnet.cpp b/src/tools/hexnet.cpp index e03da34..9088353 100644 --- a/src/tools/hexnet.cpp +++ b/src/tools/hexnet.cpp @@ -114,6 +114,26 @@ void signalHandler(int signal) { tcpSocket.shutdown(SHUT_RD); } + if (tcpConnector) { + tcpConnector.shutdown(SHUT_RD); + } + + if (tcp6Socket) { + tcp6Socket.shutdown(SHUT_RD); + } + + if (tcp6Connector) { + tcp6Connector.shutdown(SHUT_RD); + } + + if (udpSocket) { + udpSocket.shutdown(SHUT_RD); + } + + if (udp6Socket) { + udp6Socket.shutdown(SHUT_RD); + } + std::cerr << "Received signal " << signal << ", bye!" << std::endl; std::exit(EXIT_SIGNAL); }