Commit 3d068724 authored by Dan Winship's avatar Dan Winship

nm-iface-helper: small signal handling fixup

nm-iface-helper originally used the same pthread_sigmask()-based
signal handling as NetworkManager, but was then switched to using
g_unix_signal_add(). But a little bit of unnecessary code remained.
parent c5b3e937
......@@ -248,24 +248,16 @@ rdisc_ra_timeout (NMRDisc *rdisc, gpointer user_data)
static gboolean
quit_handler (gpointer user_data)
{
gboolean *quit_early_ptr = user_data;
*quit_early_ptr = TRUE;
g_main_loop_quit (main_loop);
return G_SOURCE_CONTINUE;
return G_SOURCE_REMOVE;
}
static void
setup_signals (gboolean *quit_early_ptr)
setup_signals (void)
{
sigset_t sigmask;
sigemptyset (&sigmask);
pthread_sigmask (SIG_SETMASK, &sigmask, NULL);
signal (SIGPIPE, SIG_IGN);
g_unix_signal_add (SIGINT, quit_handler, quit_early_ptr);
g_unix_signal_add (SIGTERM, quit_handler, quit_early_ptr);
g_unix_signal_add (SIGINT, quit_handler, NULL);
g_unix_signal_add (SIGTERM, quit_handler, NULL);
}
int
......@@ -280,7 +272,6 @@ main (int argc, char *argv[])
GError *error = NULL;
gboolean wrote_pidfile = FALSE;
gs_free char *pidfile = NULL;
gboolean quit_early = FALSE;
gs_unref_object NMDhcpClient *dhcp4_client = NULL;
gs_unref_object NMRDisc *rdisc = NULL;
GByteArray *hwaddr = NULL;
......@@ -375,7 +366,7 @@ main (int argc, char *argv[])
/* Set up unix signal handling - before creating threads, but after daemonizing! */
main_loop = g_main_loop_new (NULL, FALSE);
setup_signals (&quit_early);
setup_signals ();
if (g_fatal_warnings) {
GLogLevelFlags fatal_mask;
......@@ -473,8 +464,7 @@ main (int argc, char *argv[])
nm_rdisc_start (rdisc);
}
if (!quit_early)
g_main_loop_run (main_loop);
g_main_loop_run (main_loop);
g_clear_pointer (&hwaddr, g_byte_array_unref);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment