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.
This commit is contained in:
Dan Winship
2015-01-12 15:43:56 -05:00
parent 3d068724da
commit c22e3f327a
5 changed files with 5 additions and 47 deletions

View File

@@ -361,15 +361,6 @@ check_filename (const char *file_name)
return TRUE; 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 */ #define SCRIPT_TIMEOUT 600 /* 10 minutes */
static void static void
@@ -387,7 +378,7 @@ dispatch_one_script (Request *request)
if (request->debug) if (request->debug)
g_message ("Running script '%s'", script->script); 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_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); request->script_timeout_id = g_timeout_add_seconds (SCRIPT_TIMEOUT, script_timeout_cb, script);
} else { } else {

View File

@@ -4942,14 +4942,6 @@ nm_device_activate_schedule_ip6_config_timeout (NMDevice *self)
"Activation: Stage 4 of 5 (IPv6 Configure Timeout) scheduled..."); "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 static gboolean
share_init (void) share_init (void)
{ {
@@ -4979,7 +4971,7 @@ share_init (void)
GError *error = NULL; GError *error = NULL;
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_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", nm_log_err (LOGD_SHARING, "share: error loading NAT module %s: (%d) %s",
*iter, error ? error->code : 0, *iter, error ? error->code : 0,
(error && error->message) ? error->message : "unknown"); (error && error->message) ? error->message : "unknown");

View File

@@ -223,13 +223,6 @@ merge_one_ip6_config (NMResolvConfData *rc, NMIP6Config *src)
/**********************************/ /**********************************/
/* SUSE */ /* SUSE */
static void
netconfig_child_setup (gpointer user_data G_GNUC_UNUSED)
{
pid_t pid = getpid ();
setpgid (pid, pid);
}
static GPid static GPid
run_netconfig (GError **error, gint *stdin_fd) 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); nm_log_dbg (LOGD_DNS, "spawning '%s'", tmp);
g_free (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)) NULL, &pid, stdin_fd, NULL, NULL, error))
return -1; return -1;

View File

@@ -195,14 +195,6 @@ clear_share_rules (NMActRequest *req)
priv->share_rules = NULL; 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 void
nm_act_request_set_shared (NMActRequest *req, gboolean shared) 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); 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, 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", nm_log_warn (LOGD_SHARING, "Error executing command: (%d) %s",
error ? error->code : -1, error ? error->code : -1,
(error && error->message) ? error->message : "(unknown)"); (error && error->message) ? error->message : "(unknown)");

View File

@@ -43,16 +43,6 @@
#define PARSE_WARNING(msg...) nm_log_warn (LOGD_SETTINGS, " " msg) #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 '=' */ /* Removes trailing whitespace and whitespace before and immediately after the '=' */
static char * static char *
remove_most_whitespace (const char *src) 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); g_return_val_if_fail (out_blocks != NULL && *out_blocks == NULL, FALSE);
if (!g_spawn_sync ("/", (char **) argv, (char **) envp, 0, 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; goto done;
if (!WIFEXITED (status)) { if (!WIFEXITED (status)) {