mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 04:48:10 +02:00
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.
(cherry picked from commit c22e3f327a)
This commit is contained in:
parent
2397d776f5
commit
baacd13bd6
4 changed files with 4 additions and 38 deletions
|
|
@ -364,15 +364,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
|
||||||
|
|
@ -390,7 +381,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 {
|
||||||
|
|
|
||||||
|
|
@ -232,13 +232,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)
|
||||||
{
|
{
|
||||||
|
|
@ -256,7 +249,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, G_SPAWN_DO_NOT_REAP_CHILD, netconfig_child_setup,
|
if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL,
|
||||||
NULL, &pid, stdin_fd, NULL, NULL, error))
|
NULL, &pid, stdin_fd, NULL, NULL, error))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)");
|
||||||
|
|
|
||||||
|
|
@ -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)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue