Update from gettext.
authorBruno Haible <bruno@clisp.org>
Tue, 20 Jan 2004 16:47:31 +0000 (16:47 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 20 Jan 2004 16:47:31 +0000 (16:47 +0000)
lib/ChangeLog
lib/wait-process.c
lib/wait-process.h

index 4eb66fc..ea8a674 100644 (file)
@@ -1,3 +1,20 @@
+2003-12-28  Bruno Haible  <bruno@clisp.org>
+
+       * wait-process.c (wait_subprocess): Add ignore_sigpipe argument.
+       * wait-process.c (wait_subprocess): Likewise. Handle SIGPIPE specially.
+
+2003-11-28  Bruno Haible  <bruno@clisp.org>
+
+       * wait-process.c (cleanup_slaves): Use ANSI C declaration.
+
+2003-11-27  Bruno Haible  <bruno@clisp.org>
+
+       * wait-process.c: On Windows, include windows.h. Needed on mingw.
+
+2003-11-17  Bruno Haible  <bruno@clisp.org>
+
+       * wait-process.c (wait_process): Disable the 2003-10-31 waitid() patch.
+
 2003-11-24  Bruno Haible  <bruno@clisp.org>
 
        * xallocsa.h: New file, from GNU gettext.
index 26a889c..0af9a18 100644 (file)
 
 #if defined _MSC_VER || defined __MINGW32__
 
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
 /* The return value of spawnvp() is really a process handle as returned
    by CreateProcess().  Therefore we can kill it using TerminateProcess.  */
 #define kill(pid,sig) TerminateProcess ((HANDLE) (pid), sig)
@@ -140,7 +143,7 @@ static size_t slaves_allocated = SIZEOF (static_slaves);
 
 /* The cleanup action.  It gets called asynchronously.  */
 static void
-cleanup_slaves ()
+cleanup_slaves (void)
 {
   for (;;)
     {
@@ -249,10 +252,13 @@ unregister_slave_subprocess (pid_t child)
    return 127.  */
 int
 wait_subprocess (pid_t child, const char *progname,
-                bool null_stderr,
+                bool ignore_sigpipe, bool null_stderr,
                 bool slave_process, bool exit_on_error)
 {
-#if HAVE_WAITID && defined WNOWAIT
+#if HAVE_WAITID && defined WNOWAIT && 0
+  /* Commented out because waitid() with WNOWAIT doesn't work: On Solaris 7
+     and OSF/1 4.0, it returns -1 and sets errno = ECHILD, and on HP-UX 10.20
+     it just hangs.  */
   /* Use of waitid() with WNOWAIT avoids a race condition: If slave_process is
      true, and this process sleeps a very long time between the return from
      waitpid() and the execution of unregister_slave_subprocess(), and
@@ -313,6 +319,10 @@ wait_subprocess (pid_t child, const char *progname,
     {
     case CLD_KILLED:
     case CLD_DUMPED:
+# ifdef SIGPIPE
+      if (info.si_status == SIGPIPE && ignore_sigpipe)
+       return 0;
+# endif
       if (exit_on_error || !null_stderr)
        error (exit_on_error ? EXIT_FAILURE : 0, 0,
               _("%s subprocess got fatal signal %d"),
@@ -376,6 +386,10 @@ wait_subprocess (pid_t child, const char *progname,
 
   if (WIFSIGNALED (status))
     {
+# ifdef SIGPIPE
+      if (WTERMSIG (status) == SIGPIPE && ignore_sigpipe)
+       return 0;
+# endif
       if (exit_on_error || !null_stderr)
        error (exit_on_error ? EXIT_FAILURE : 0, 0,
               _("%s subprocess got fatal signal %d"),
index 2200142..0d117f3 100644 (file)
@@ -36,9 +36,23 @@ extern "C" {
 
 /* Wait for a subprocess to finish.  Return its exit code.
    If it didn't terminate correctly, exit if exit_on_error is true, otherwise
-   return 127.  */
+   return 127.
+   Arguments:
+   - child is the pid of the subprocess.
+   - progname is the name of the program executed by the subprocess, used for
+     error messages.
+   - If ignore_sigpipe is true, consider a subprocess termination due to
+     SIGPIPE as equivalent to a success.  This is suitable for processes whose
+     only purpose is to write to standard output.  This flag can be safely set
+     to false when the process' standard output is known to go to DEV_NULL.
+   - If null_stderr is true, the usual error message to stderr will be omitted.
+     This is suitable when the subprocess does not fulfill an important task.
+   - slave_process should be set to true if the process has been launched as a
+     slave process.
+   - If exit_on_error is true, any error will cause the main process to exit
+     with an error status.  */
 extern int wait_subprocess (pid_t child, const char *progname,
-                           bool null_stderr,
+                           bool ignore_sigpipe, bool null_stderr,
                            bool slave_process, bool exit_on_error);
 
 /* Register a subprocess as being a slave process.  This means that the