mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 07:13:03 +00:00 
			
		
		
		
	Move signal handler after the constructor
This commit is contained in:
		| @@ -81,33 +81,6 @@ extern Concurrent_Queue<Gps_Acq_Assist> global_gps_acq_assist_queue; | |||||||
|  |  | ||||||
| ControlThread *ControlThread::me = nullptr; | 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::ControlThread() | ||||||
| { | { | ||||||
|     ControlThread::me = this; |     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() | void ControlThread::telecommand_listener() | ||||||
| { | { | ||||||
|     if (telecommand_enabled_) |     if (telecommand_enabled_) | ||||||
|   | |||||||
| @@ -124,6 +124,10 @@ public: | |||||||
|     } |     } | ||||||
|  |  | ||||||
| private: | private: | ||||||
|  |     /* | ||||||
|  |      * Callback function for handling signals. | ||||||
|  |      * sig   identifier of signal | ||||||
|  |      */ | ||||||
|     static void handle_signal(int sig); |     static void handle_signal(int sig); | ||||||
|  |  | ||||||
|     void init(); |     void init(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez