From 102befe7316522c8a1aca539018188fd97858732 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 17 Jan 2025 20:33:19 -0800 Subject: [PATCH] remove signal handler (#641) --- msgq/impl_msgq.cc | 37 +++---------------------------------- msgq/ipc_pyx.pyx | 5 ----- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/msgq/impl_msgq.cc b/msgq/impl_msgq.cc index b23991351..01db7236d 100644 --- a/msgq/impl_msgq.cc +++ b/msgq/impl_msgq.cc @@ -2,20 +2,10 @@ #include #include #include -#include #include #include "msgq/impl_msgq.h" - -volatile sig_atomic_t msgq_do_exit = 0; - -void sig_handler(int signal) { - assert(signal == SIGINT || signal == SIGTERM); - msgq_do_exit = 1; -} - - MSGQContext::MSGQContext() { } @@ -72,15 +62,6 @@ int MSGQSubSocket::connect(Context *context, std::string endpoint, std::string a Message * MSGQSubSocket::receive(bool non_blocking){ - msgq_do_exit = 0; - - void (*prev_handler_sigint)(int); - void (*prev_handler_sigterm)(int); - if (!non_blocking){ - prev_handler_sigint = std::signal(SIGINT, sig_handler); - prev_handler_sigterm = std::signal(SIGTERM, sig_handler); - } - msgq_msg_t msg; MSGQMessage *r = NULL; @@ -88,7 +69,7 @@ Message * MSGQSubSocket::receive(bool non_blocking){ int rc = msgq_msg_recv(&msg, q); // Hack to implement blocking read with a poller. Don't use this - while (!non_blocking && rc == 0 && msgq_do_exit == 0){ + while (!non_blocking && rc == 0){ msgq_pollitem_t items[1]; items[0].q = q; @@ -107,21 +88,9 @@ Message * MSGQSubSocket::receive(bool non_blocking){ } } - - if (!non_blocking){ - std::signal(SIGINT, prev_handler_sigint); - std::signal(SIGTERM, prev_handler_sigterm); - } - - errno = msgq_do_exit ? EINTR : 0; - if (rc > 0){ - if (msgq_do_exit){ - msgq_msg_close(&msg); // Free unused message on exit - } else { - r = new MSGQMessage; - r->takeOwnership(msg.data, msg.size); - } + r = new MSGQMessage; + r->takeOwnership(msg.data, msg.size); } return (Message*)r; diff --git a/msgq/ipc_pyx.pyx b/msgq/ipc_pyx.pyx index d8797f395..ee2603ae6 100644 --- a/msgq/ipc_pyx.pyx +++ b/msgq/ipc_pyx.pyx @@ -199,11 +199,6 @@ cdef class SubSocket: msg = self.socket.receive(non_blocking) if msg == NULL: - # If a blocking read returns no message check errno if SIGINT was caught in the C++ code - if errno.errno == errno.EINTR: - print("SIGINT received, exiting") - sys.exit(1) - return None else: sz = msg.getSize()