From 707c7826fbeae69d68c7a12f6da2756f058bec04 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 5 Oct 2023 17:47:13 +0200 Subject: [PATCH] Move signal handler after the constructor --- src/core/receiver/control_thread.cc | 49 +++++++++++++---------------- src/core/receiver/control_thread.h | 4 +++ 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 00ebe5129..a6791fd52 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -81,33 +81,6 @@ extern Concurrent_Queue global_gps_acq_assist_queue; ControlThread *ControlThread::me = nullptr; - -/** - * \brief Callback function for handling signals. - * \param sig identifier of signal - */ -void ControlThread::handle_signal(int sig) -{ - LOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; - if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP) - { - ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); - ControlThread::me->stop_ = true; - - // Reset signal handling to default behavior - if (sig == SIGINT) - { - signal(SIGINT, SIG_DFL); - } - } - else if (sig == SIGCHLD) - { - LOG(INFO) << "Received SIGCHLD signal"; - // todo - } -} - - ControlThread::ControlThread() { ControlThread::me = this; @@ -302,6 +275,28 @@ ControlThread::~ControlThread() // NOLINT(modernize-use-equals-default) } +void ControlThread::handle_signal(int sig) +{ + LOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; + if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP) + { + ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); + ControlThread::me->stop_ = true; + + // Reset signal handling to default behavior + if (sig == SIGINT) + { + signal(SIGINT, SIG_DFL); + } + } + else if (sig == SIGCHLD) + { + LOG(INFO) << "Received SIGCHLD signal"; + // todo + } +} + + void ControlThread::telecommand_listener() { if (telecommand_enabled_) diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index 217ad28bb..b3340e94b 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -124,6 +124,10 @@ public: } private: + /* + * Callback function for handling signals. + * sig identifier of signal + */ static void handle_signal(int sig); void init();