]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Don't die from SIGPIPE.
authorBruno Haible <bruno@clisp.org>
Sun, 28 Sep 2008 13:55:13 +0000 (13:55 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:53 +0000 (12:15 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/msgexec.c

index 577688c976161cc4545322d8e5377d40fffc4381..9d59640ecf73977c9ac53c6448fbe7ac94912d5b 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-28  Bruno Haible  <bruno@clisp.org>
+
+       * msgexec.c (process_string): Don't die from SIGPIPE if the subprocess
+       does not want our input.
+       Reported by Rainer Tammer <tammer@tammer.net>.
+
 2008-09-28  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (msgcmp_LDADD): Add MSGMERGE_LIBM.
index 2db3f23b0887174212abac4dd072006981e7d567..29034262e58294b86e521cf4bf96b173899eb0af 100644 (file)
@@ -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...  */