summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-11-06 18:14:45 -0600
committerDan Williams <dcbw@redhat.com>2014-11-07 11:23:34 -0600
commit6824be0da73e6b69783caf837f8ec48833675774 (patch)
tree1b63f23a036c13bf684691979e2e1ede369162c4
parentfec757687d901d67f7e6d2ed2358e931b4486093 (diff)
downloadNetworkManager-6824be0da73e6b69783caf837f8ec48833675774.tar.gz
fixup! iface-helper: add nm-iface-helper for dynamic configure-then-quit support
-rw-r--r--src/devices/nm-device.c18
-rw-r--r--src/nm-iface-helper.c8
2 files changed, 10 insertions, 16 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 27e758c056..46ff9ea1de 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7027,20 +7027,6 @@ find_dhcp4_address (NMDevice *self)
return NULL;
}
-static void
-iface_helper_child_setup (gpointer user_data G_GNUC_UNUSED)
-{
- /* We are in the child process at this point */
- pid_t pid = getpid ();
- setpgid (pid, pid);
-
- /*
- * We blocked signals in main(). We need to restore original signal
- * mask for the helper here so that it can receive signals.
- */
- nm_unblock_posix_signals (NULL);
-}
-
void
nm_device_spawn_iface_helper (NMDevice *self)
{
@@ -7159,8 +7145,8 @@ nm_device_spawn_iface_helper (NMDevice *self)
g_free (tmp);
}
- if (g_spawn_async (NULL, (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
- iface_helper_child_setup, NULL, &pid, &error)) {
+ if (g_spawn_async (NULL, (char **) argv->pdata, NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &error)) {
_LOGI (LOGD_DEVICE, "spawned helper PID %u", (guint) pid);
} else {
_LOGW (LOGD_DEVICE, "failed to spawn helper: %s", error->message);
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index bce59bfed6..501bacc45b 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <sys/resource.h>
#include <sys/stat.h>
+#include <signal.h>
#include "gsystem-local-alloc.h"
#include "NetworkManagerUtils.h"
@@ -255,6 +256,11 @@ quit_handler (gpointer user_data)
static void
setup_signals (gboolean *quit_early_ptr)
{
+ 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);
@@ -307,6 +313,8 @@ main (int argc, char *argv[])
{NULL}
};
+ setpgid (getpid (), getpid ());
+
if (!nm_main_utils_early_setup ("nm-iface-helper",
&argv,
&argc,