]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
SIGPIPE handling.
authorBruno Haible <bruno@clisp.org>
Sun, 31 Aug 2008 13:54:18 +0000 (13:54 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:49 +0000 (12:15 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/msgexec.c

index d58682bd1c6a5ebf683bf51512e8f70fcc37879e..c91fd670a01d96420e9c9d27524776d0b5bbea5e 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-31  Bruno Haible  <bruno@clisp.org>
+
+       * msgexec.c: Include <signal.h>.
+       (main): Block SIGPIPE for the duration of the processing.
+
 2008-08-23  Bruno Haible  <bruno@clisp.org>
 
        Fix behaviour of "msgmerge --update" when sorting is requested and
index 345044dfc45f3b42255114f05b60c89152d6a488..2db3f23b0887174212abac4dd072006981e7d567 100644 (file)
@@ -24,6 +24,7 @@
 #include <getopt.h>
 #include <limits.h>
 #include <locale.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -210,6 +211,18 @@ There is NO WARRANTY, to the extent permitted by law.\n\
 
   if (strcmp (sub_name, "0") != 0)
     {
+      /* Block SIGPIPE for this process and for the subprocesses.
+        The subprogram may have side effects (additionally to producing some
+        output), therefore if there are no readers on stdout, processing of the
+        strings must continue nevertheless.  */
+      {
+       sigset_t sigpipe_set;
+
+       sigemptyset (&sigpipe_set);
+       sigaddset (&sigpipe_set, SIGPIPE);
+       sigprocmask (SIG_UNBLOCK, &sigpipe_set, NULL);
+      }
+
       /* Attempt to locate the program.
         This is an optimization, to avoid that spawn/exec searches the PATH
         on every call.  */