From 02e1127f5a26e1823a382d86e68f84dce03f7cd0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 28 Sep 2008 13:55:13 +0000 Subject: [PATCH] Don't die from SIGPIPE. --- gettext-tools/src/ChangeLog | 6 ++++++ gettext-tools/src/msgexec.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 577688c97..9d59640ec 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,9 @@ +2008-09-28 Bruno Haible + + * msgexec.c (process_string): Don't die from SIGPIPE if the subprocess + does not want our input. + Reported by Rainer Tammer . + 2008-09-28 Bruno Haible * Makefile.am (msgcmp_LDADD): Add MSGMERGE_LIBM. diff --git a/gettext-tools/src/msgexec.c b/gettext-tools/src/msgexec.c index 2db3f23b0..29034262e 100644 --- a/gettext-tools/src/msgexec.c +++ b/gettext-tools/src/msgexec.c @@ -346,6 +346,7 @@ process_string (const message_ty *mp, const char *str, size_t len) char *location; pid_t child; int fd[1]; + void (*orig_sigpipe_handler)(int); int exitstatus; /* Set environment variables for the subprocess. */ @@ -363,12 +364,19 @@ process_string (const message_ty *mp, const char *str, size_t len) child = create_pipe_out (sub_name, sub_path, sub_argv, NULL, false, true, true, fd); + /* Ignore SIGPIPE here. We don't care if the subprocesses terminates + successfully without having read all of the input that we feed it. */ + orig_sigpipe_handler = signal (SIGPIPE, SIG_IGN); + if (full_write (fd[0], str, len) < len) - error (EXIT_FAILURE, errno, - _("write to %s subprocess failed"), sub_name); + if (errno != EPIPE) + error (EXIT_FAILURE, errno, + _("write to %s subprocess failed"), sub_name); close (fd[0]); + signal (SIGPIPE, orig_sigpipe_handler); + /* Remove zombie process from process list, and retrieve exit status. */ /* FIXME: Should ignore_sigpipe be set to true here? It depends on the semantics of the subprogram... */ -- 2.47.2