dispatcher: setup signal handler as first

The very first and the very last thing we want to do is
register (unregister) the signal handler.
This commit is contained in:
Thomas Haller 2021-08-03 09:30:47 +02:00
parent 33b643414f
commit e21db61b6d
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -996,15 +996,15 @@ main(int argc, char **argv)
guint dbus_regist_id = 0;
guint dbus_own_name_id = 0;
source_term = nm_g_unix_signal_add_source(SIGTERM, signal_handler, GINT_TO_POINTER(SIGTERM));
source_int = nm_g_unix_signal_add_source(SIGINT, signal_handler, GINT_TO_POINTER(SIGINT));
if (!parse_command_line(&argc, &argv, &error)) {
_LOG_X_W("Error parsing command line arguments: %s", error->message);
gl.exit_with_failure = TRUE;
goto done;
}
source_term = nm_g_unix_signal_add_source(SIGTERM, signal_handler, GINT_TO_POINTER(SIGTERM));
source_int = nm_g_unix_signal_add_source(SIGINT, signal_handler, GINT_TO_POINTER(SIGINT));
if (gl.debug) {
if (!g_getenv("G_MESSAGES_DEBUG")) {
/* we log our regular messages using g_debug() and g_info().
@ -1084,13 +1084,14 @@ done:
nm_clear_pointer(&gl.requests_waiting, g_queue_free);
nm_clear_g_source_inst(&source_term);
nm_clear_g_source_inst(&source_int);
nm_clear_g_source_inst(&gl.quit_source);
g_clear_object(&gl.dbus_connection);
if (!gl.debug)
logging_shutdown();
nm_clear_g_source_inst(&source_term);
nm_clear_g_source_inst(&source_int);
return gl.exit_with_failure ? 1 : 0;
}