]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Emit error message even if exit_on_error == false and null_stderr == false.
authorBruno Haible <bruno@clisp.org>
Fri, 13 Jun 2003 13:03:11 +0000 (13:03 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:40 +0000 (12:10 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/execute.c
gettext-tools/lib/javacomp.c
gettext-tools/lib/pipe-bidi.c
gettext-tools/lib/pipe-in.c
gettext-tools/lib/pipe-out.c
gettext-tools/lib/pipe.h
gettext-tools/lib/wait-process.c
gettext-tools/lib/wait-process.h

index 7e6683963d79f21969ee0c759d699a61d16c6be2..7d8431a68a87f878256bfb211ea62b00845dddbf 100644 (file)
@@ -1,4 +1,18 @@
-2003-05-08  Bruno Haible  <bruno@clisp.org>
+2003-06-13  Bruno Haible  <bruno@clisp.org>
+
+       * wait-process.h (wait_subprocess): Add null_stderr argument.
+       * wait-process.c (wait_subprocess): Add null_stderr argument.
+       When !exit_on_error && !null_stderr, still emit error messages, but
+       don't exit.
+       * execute.c (execute): When !exit_on_error && !null_stderr, still
+       emit error messages, but don't exit. Update wait_subprocess call.
+       * pipe-in.c (create_pipe_in): When !exit_on_error && !null_stderr,
+       still emit error messages, but don't exit.
+       * pipe-out.c (create_pipe_out): Likewise.
+       * pipe-bidi.c (create_pipe_bidi): Likewise.
+       * javacomp.c (compile_java_class): Update wait_subprocess call.
+
+2003-06-08  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.vms (alloca.h): New rule.
        (all, javacomp.obj, javaexec.obj): Depend on it.
index 3c8be27c104448fb3ae5ffec76641d5074e74692..debc4292768f08ae355aa5233d492f7b1a596f1f 100644 (file)
@@ -172,10 +172,10 @@ execute (const char *progname,
 
   if (exitcode == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       return 127;
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      return 127;
     }
 
   return exitcode;
@@ -225,10 +225,10 @@ execute (const char *progname,
     {
       if (actions_allocated)
        posix_spawn_file_actions_destroy (&actions);
-      if (exit_on_error)
-       error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
-      else
-       return 127;
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, err,
+              _("%s subprocess failed"), progname);
+      return 127;
     }
   posix_spawn_file_actions_destroy (&actions);
 #else
@@ -260,14 +260,14 @@ execute (const char *progname,
     }
   if (child == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       return 127;
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      return 127;
     }
 #endif
 
-  return wait_subprocess (child, progname, exit_on_error);
+  return wait_subprocess (child, progname, null_stderr, exit_on_error);
 
 #endif
 }
index 21e63f783577920dd7a722c33eba1d4f892a1502..6265777b2684865c897cca4241547c24c722adda 100644 (file)
@@ -235,7 +235,7 @@ compile_java_class (const char * const *java_sources,
 
            /* Remove zombie process from process list, and retrieve exit
               status.  */
-           exitstatus = wait_subprocess (child, "gcj", false);
+           exitstatus = wait_subprocess (child, "gcj", true, false);
            if (exitstatus != 0)
              gcj_present = false;
          }
index 5c8b4d9711f9974bc53cbcfabbf66e26851c76ac..aca7ccaa4c0ec509554b3e01764c3888dddd7b0b 100644 (file)
@@ -170,14 +170,12 @@ create_pipe_bidi (const char *progname,
   close (ifd[1]);
   if (child == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ifd[0]);
-         close (ofd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      close (ifd[0]);
+      close (ofd[1]);
+      return -1;
     }
 
   fd[0] = ifd[0];
@@ -235,16 +233,14 @@ create_pipe_bidi (const char *progname,
     {
       if (actions_allocated)
        posix_spawn_file_actions_destroy (&actions);
-      if (exit_on_error)
-       error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ifd[0]);
-         close (ifd[1]);
-         close (ofd[0]);
-         close (ofd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, err,
+              _("%s subprocess failed"), progname);
+      close (ifd[0]);
+      close (ifd[1]);
+      close (ofd[0]);
+      close (ofd[1]);
+      return -1;
     }
   posix_spawn_file_actions_destroy (&actions);
 #else
@@ -270,16 +266,14 @@ create_pipe_bidi (const char *progname,
     }
   if (child == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ifd[0]);
-         close (ifd[1]);
-         close (ofd[0]);
-         close (ofd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      close (ifd[0]);
+      close (ifd[1]);
+      close (ofd[0]);
+      close (ofd[1]);
+      return -1;
     }
 #endif
   close (ofd[0]);
index 53a791efcd53188f0a25ae2fe396b7760ca14fd5..8f99487177c8807631dae5fe20acf377f28d2668 100644 (file)
@@ -186,13 +186,11 @@ create_pipe_in (const char *progname,
   close (ifd[1]);
   if (child == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ifd[0]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      close (ifd[0]);
+      return -1;
     }
 
   fd[0] = ifd[0];
@@ -244,14 +242,12 @@ create_pipe_in (const char *progname,
     {
       if (actions_allocated)
        posix_spawn_file_actions_destroy (&actions);
-      if (exit_on_error)
-       error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ifd[0]);
-         close (ifd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, err,
+              _("%s subprocess failed"), progname);
+      close (ifd[0]);
+      close (ifd[1]);
+      return -1;
     }
   posix_spawn_file_actions_destroy (&actions);
 #else
@@ -280,14 +276,12 @@ create_pipe_in (const char *progname,
     }
   if (child == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ifd[0]);
-         close (ifd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      close (ifd[0]);
+      close (ifd[1]);
+      return -1;
     }
 #endif
   close (ifd[1]);
index d943b940eebe3194103803cd90a6405f0bfa800f..304ed1ef83737627a8cc3fff8947ab20278e86e7 100644 (file)
@@ -186,13 +186,11 @@ create_pipe_out (const char *progname,
   close (ofd[0]);
   if (child == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ofd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      close (ofd[1]);
+      return -1;
     }
 
   fd[0] = ofd[1];
@@ -244,14 +242,12 @@ create_pipe_out (const char *progname,
     {
       if (actions_allocated)
        posix_spawn_file_actions_destroy (&actions);
-      if (exit_on_error)
-       error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ofd[0]);
-         close (ofd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, err,
+              _("%s subprocess failed"), progname);
+      close (ofd[0]);
+      close (ofd[1]);
+      return -1;
     }
   posix_spawn_file_actions_destroy (&actions);
 #else
@@ -280,14 +276,12 @@ create_pipe_out (const char *progname,
     }
   if (child == -1)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
-      else
-       {
-         close (ofd[0]);
-         close (ofd[1]);
-         return -1;
-       }
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, errno,
+              _("%s subprocess failed"), progname);
+      close (ofd[0]);
+      close (ofd[1]);
+      return -1;
     }
 #endif
   close (ofd[0]);
index 97e02ac087923d7f53fedafbdf86e6baa768fdf5..de8f79047473e5c5bbb34dcbcb86b74bdb5513c8 100644 (file)
@@ -32,8 +32,8 @@
    They return the process id of the subprocess.  They also return in fd[]
    one or two file descriptors for communication with the subprocess.
    If the subprocess creation fails: if exit_on_error is true, the main
-   process exits with an error message; otherwise, -1 is returned and fd[]
-   remain uninitialized.
+   process exits with an error message; otherwise, an error message is given
+   if null_stderr is false, then -1 is returned and fd[] remain uninitialized.
 
    After finishing communication, the caller should call wait_subprocess()
    to get rid of the subprocess in the process table.
index df257639fd189f8f500e190fcd46eab57e137c1d..3d9f91a116af28270a5cc4045a8b1d619cdfd9a7 100644 (file)
@@ -96,7 +96,8 @@
 
 
 int
-wait_subprocess (pid_t child, const char *progname, bool exit_on_error)
+wait_subprocess (pid_t child, const char *progname,
+                bool null_stderr, bool exit_on_error)
 {
   /* waitpid() is just as portable as wait() nowadays.  */
   WAIT_T status;
@@ -121,10 +122,10 @@ wait_subprocess (pid_t child, const char *progname, bool exit_on_error)
              break;
            }
 #endif
-         if (exit_on_error)
-           error (EXIT_FAILURE, errno, _("%s subprocess"), progname);
-         else
-           return 127;
+         if (exit_on_error || !null_stderr)
+           error (exit_on_error ? EXIT_FAILURE : 0, errno,
+                  _("%s subprocess"), progname);
+         return 127;
        }
 
       /* One of WIFSIGNALED (status), WIFEXITED (status), WIFSTOPPED (status)
@@ -135,18 +136,18 @@ wait_subprocess (pid_t child, const char *progname, bool exit_on_error)
 
   if (WIFSIGNALED (status))
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, 0, _("%s subprocess got fatal signal %d"),
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, 0,
+              _("%s subprocess got fatal signal %d"),
               progname, (int) WTERMSIG (status));
-      else
-       return 127;
+      return 127;
     }
   if (WEXITSTATUS (status) == 127)
     {
-      if (exit_on_error)
-       error (EXIT_FAILURE, 0, _("%s subprocess failed"), progname);
-      else
-       return 127;
+      if (exit_on_error || !null_stderr)
+       error (exit_on_error ? EXIT_FAILURE : 0, 0,
+              _("%s subprocess failed"), progname);
+      return 127;
     }
   return WEXITSTATUS (status);
 }
index 22440f4107e58cda828474c230eed02415e19a61..5b31c766af885d410c97e33718a8248d9c103e16 100644 (file)
@@ -1,5 +1,5 @@
 /* Waiting for a subprocess to finish.
-   Copyright (C) 2001-2002 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -32,6 +32,6 @@
    If it didn't terminate correctly, exit if exit_on_error is true, otherwise
    return 127.  */
 extern int wait_subprocess (pid_t child, const char *progname,
-                           bool exit_on_error);
+                           bool null_stderr, bool exit_on_error);
 
 #endif /* _WAIT_PROCESS_H */