summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@redhat.com>2015-01-12 15:43:56 -0500
committerDan Winship <danw@redhat.com>2015-01-19 11:29:13 -0500
commitc22e3f327aac18c0b3f2ab76fc6b60fbb467d898 (patch)
tree526ddc71c1959791464396427761a4a50943d2bc
parent3d068724da97adf2c56a42893f8aa9a26a5aea5d (diff)
downloadNetworkManager-c22e3f327aac18c0b3f2ab76fc6b60fbb467d898.tar.gz
core, dispatcher: drop unnecessary setpgid() calls
There's no point in calling setpgid() on short-lived processes, so remove the setpgid() calls when spawning dispatcher scripts, iptables, iscsiadmin, and netconf.
-rw-r--r--callouts/nm-dispatcher.c11
-rw-r--r--src/devices/nm-device.c10
-rw-r--r--src/dns-manager/nm-dns-manager.c9
-rw-r--r--src/nm-activation-request.c10
-rw-r--r--src/settings/plugins/ibft/reader.c12
5 files changed, 5 insertions, 47 deletions
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c
index 0cd2531dda..6fb40cf9f3 100644
--- a/callouts/nm-dispatcher.c
+++ b/callouts/nm-dispatcher.c
@@ -361,15 +361,6 @@ check_filename (const char *file_name)
return TRUE;
}
-static void
-child_setup (gpointer user_data G_GNUC_UNUSED)
-{
- /* We are in the child process at this point */
- /* Give child a different process group to ensure signal separation. */
- pid_t pid = getpid ();
- setpgid (pid, pid);
-}
-
#define SCRIPT_TIMEOUT 600 /* 10 minutes */
static void
@@ -387,7 +378,7 @@ dispatch_one_script (Request *request)
if (request->debug)
g_message ("Running script '%s'", script->script);
- if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, child_setup, request, &script->pid, &error)) {
+ if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, NULL, request, &script->pid, &error)) {
request->script_watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script);
request->script_timeout_id = g_timeout_add_seconds (SCRIPT_TIMEOUT, script_timeout_cb, script);
} else {
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e478d05f36..566ab055cc 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4942,14 +4942,6 @@ nm_device_activate_schedule_ip6_config_timeout (NMDevice *self)
"Activation: Stage 4 of 5 (IPv6 Configure Timeout) scheduled...");
}
-static void
-share_child_setup (gpointer user_data G_GNUC_UNUSED)
-{
- /* We are in the child process at this point */
- pid_t pid = getpid ();
- setpgid (pid, pid);
-}
-
static gboolean
share_init (void)
{
@@ -4979,7 +4971,7 @@ share_init (void)
GError *error = NULL;
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
- share_child_setup, NULL, NULL, NULL, &status, &error)) {
+ NULL, NULL, NULL, NULL, &status, &error)) {
nm_log_err (LOGD_SHARING, "share: error loading NAT module %s: (%d) %s",
*iter, error ? error->code : 0,
(error && error->message) ? error->message : "unknown");
diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c
index c8098736fe..47e3f123f1 100644
--- a/src/dns-manager/nm-dns-manager.c
+++ b/src/dns-manager/nm-dns-manager.c
@@ -223,13 +223,6 @@ merge_one_ip6_config (NMResolvConfData *rc, NMIP6Config *src)
/**********************************/
/* SUSE */
-static void
-netconfig_child_setup (gpointer user_data G_GNUC_UNUSED)
-{
- pid_t pid = getpid ();
- setpgid (pid, pid);
-}
-
static GPid
run_netconfig (GError **error, gint *stdin_fd)
{
@@ -247,7 +240,7 @@ run_netconfig (GError **error, gint *stdin_fd)
nm_log_dbg (LOGD_DNS, "spawning '%s'", tmp);
g_free (tmp);
- if (!g_spawn_async_with_pipes (NULL, argv, NULL, 0, netconfig_child_setup,
+ if (!g_spawn_async_with_pipes (NULL, argv, NULL, 0, NULL,
NULL, &pid, stdin_fd, NULL, NULL, error))
return -1;
diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c
index d6ed34fdae..2c084b874e 100644
--- a/src/nm-activation-request.c
+++ b/src/nm-activation-request.c
@@ -195,14 +195,6 @@ clear_share_rules (NMActRequest *req)
priv->share_rules = NULL;
}
-static void
-share_child_setup (gpointer user_data G_GNUC_UNUSED)
-{
- /* We are in the child process at this point */
- pid_t pid = getpid ();
- setpgid (pid, pid);
-}
-
void
nm_act_request_set_shared (NMActRequest *req, gboolean shared)
{
@@ -240,7 +232,7 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared)
nm_log_info (LOGD_SHARING, "Executing: %s", cmd);
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
- share_child_setup, NULL, NULL, NULL, &status, &error)) {
+ NULL, NULL, NULL, NULL, &status, &error)) {
nm_log_warn (LOGD_SHARING, "Error executing command: (%d) %s",
error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)");
diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c
index 648ed8926b..0d77871f42 100644
--- a/src/settings/plugins/ibft/reader.c
+++ b/src/settings/plugins/ibft/reader.c
@@ -43,16 +43,6 @@
#define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg)
-static void
-iscsiadm_child_setup (gpointer user_data G_GNUC_UNUSED)
-{
- /* We are in the child process here; set a different process group to
- * ensure signal isolation between child and parent.
- */
- pid_t pid = getpid ();
- setpgid (pid, pid);
-}
-
/* Removes trailing whitespace and whitespace before and immediately after the '=' */
static char *
remove_most_whitespace (const char *src)
@@ -119,7 +109,7 @@ read_ibft_blocks (const char *iscsiadm_path,
g_return_val_if_fail (out_blocks != NULL && *out_blocks == NULL, FALSE);
if (!g_spawn_sync ("/", (char **) argv, (char **) envp, 0,
- iscsiadm_child_setup, NULL, &out, &err, &status, error))
+ NULL, NULL, &out, &err, &status, error))
goto done;
if (!WIFEXITED (status)) {