From c730fa74f5b201a2997734330b3598c706179d74 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Wed, 19 Oct 2016 14:24:49 +0200 Subject: [PATCH] Re-enable SIGPIPE for children so they have default behaviour --- src/lightdm.c | 6 ++++++ src/process.c | 3 +++ src/session-child.c | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/lightdm.c b/src/lightdm.c index e64fc874..fd62314c 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -1225,6 +1225,12 @@ main (int argc, char **argv) }; GError *error = NULL; + /* Disable the SIGPIPE handler - this is a stupid Unix hangover behaviour. + * We will handle piples / sockets being closed instead of having the whole daemon be killed... + * http://stackoverflow.com/questions/8369506/why-does-sigpipe-exist + */ + signal (SIGPIPE, SIG_IGN); + /* When lightdm starts sessions it needs to run itself in a new mode */ if (argc >= 2 && strcmp (argv[1], "--session-child") == 0) return session_child_run (argc, argv); diff --git a/src/process.c b/src/process.c index d9b7eb9a..75357db6 100644 --- a/src/process.c +++ b/src/process.c @@ -236,6 +236,9 @@ process_start (Process *process, gboolean block) for (i = 0; i < env_length; i++) setenv (env_keys[i], env_values[i], TRUE); + /* Reset SIGPIPE handler so the child has default behaviour (we disabled it at LightDM start) */ + signal (SIGPIPE, SIG_DFL); + execvp (argv[0], argv); _exit (EXIT_FAILURE); } diff --git a/src/session-child.c b/src/session-child.c index e393ce4c..fb12d9b8 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -704,6 +704,9 @@ session_child_run (int argc, char **argv) } } + /* Reset SIGPIPE handler so the child has default behaviour (we disabled it at LightDM start) */ + signal (SIGPIPE, SIG_DFL); + /* Run the command */ execve (command_argv[0], command_argv, pam_getenvlist (pam_handle)); _exit (EXIT_FAILURE); -- 2.39.2