From a6d34f9ae348603eebc1e53067c164ab352293d3 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 10 Nov 2016 14:59:37 +0100 Subject: 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 --- src/devices/team/nm-device-team.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/devices/team/nm-device-team.c') diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 07ed092cba..ab195c886a 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -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; -- cgit v1.2.1