team: ignore SIGPIPE when spawning teamd

With systemd < 219, restarting the journald service closes the stdout
and stderr streams associated with services.

The NM process has SIGPIPE ignored, but g_spawn_sync()/g_spawn_async()
re-enable it and so any child executed with those functions will
terminate by default if it tries to log anything to stdout/stderr.

The teamd instance launched by NM is affected by this problem since it
writes debug messages before actually ignoring SIGPIPE.

To fix this, use the @child_setup callback of g_spawn() to ignore
again SIGPIPE in the child process.

https://bugzilla.redhat.com/show_bug.cgi?id=1393853
This commit is contained in:
Beniamino Galvani 2016-11-10 14:59:37 +01:00
parent cb61dd113c
commit a6d34f9ae3

View file

@ -480,6 +480,13 @@ teamd_process_watch_cb (GPid pid, gint status, gpointer user_data)
}
}
static void
teamd_child_setup (gpointer user_data)
{
nm_utils_setpgid (NULL);
signal (SIGPIPE, SIG_IGN);
}
static gboolean
teamd_kill (NMDeviceTeam *self, const char *teamd_binary, GError **error)
{
@ -502,7 +509,7 @@ teamd_kill (NMDeviceTeam *self, const char *teamd_binary, GError **error)
g_ptr_array_add (argv, NULL);
_LOGD (LOGD_TEAM, "running: %s", (tmp_str = g_strjoinv (" ", (gchar **) argv->pdata)));
return g_spawn_sync ("/", (char **) argv->pdata, NULL, 0, NULL, NULL, NULL, NULL, NULL, error);
return g_spawn_sync ("/", (char **) argv->pdata, NULL, 0, teamd_child_setup, NULL, NULL, NULL, NULL, error);
}
static gboolean
@ -553,7 +560,7 @@ teamd_start (NMDevice *device, NMSettingTeam *s_team)
_LOGD (LOGD_TEAM, "running: %s", (tmp_str = g_strjoinv (" ", (gchar **) argv->pdata)));
if (!g_spawn_async ("/", (char **) argv->pdata, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
nm_utils_setpgid, NULL, &priv->teamd_pid, &error)) {
teamd_child_setup, NULL, &priv->teamd_pid, &error)) {
_LOGW (LOGD_TEAM, "Activation: (team) failed to start teamd: %s", error->message);
teamd_cleanup (device, TRUE);
return FALSE;