From: Bruno Haible Date: Fri, 13 Jun 2003 13:03:11 +0000 (+0000) Subject: Emit error message even if exit_on_error == false and null_stderr == false. X-Git-Tag: v0.13~451 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b88fe763052a5fa932ae944915c438145221ea73;p=thirdparty%2Fgettext.git Emit error message even if exit_on_error == false and null_stderr == false. --- diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 7e6683963..7d8431a68 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,4 +1,18 @@ -2003-05-08 Bruno Haible +2003-06-13 Bruno Haible + + * 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 * Makefile.vms (alloca.h): New rule. (all, javacomp.obj, javaexec.obj): Depend on it. diff --git a/gettext-tools/lib/execute.c b/gettext-tools/lib/execute.c index 3c8be27c1..debc42927 100644 --- a/gettext-tools/lib/execute.c +++ b/gettext-tools/lib/execute.c @@ -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 } diff --git a/gettext-tools/lib/javacomp.c b/gettext-tools/lib/javacomp.c index 21e63f783..6265777b2 100644 --- a/gettext-tools/lib/javacomp.c +++ b/gettext-tools/lib/javacomp.c @@ -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; } diff --git a/gettext-tools/lib/pipe-bidi.c b/gettext-tools/lib/pipe-bidi.c index 5c8b4d971..aca7ccaa4 100644 --- a/gettext-tools/lib/pipe-bidi.c +++ b/gettext-tools/lib/pipe-bidi.c @@ -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]); diff --git a/gettext-tools/lib/pipe-in.c b/gettext-tools/lib/pipe-in.c index 53a791efc..8f9948717 100644 --- a/gettext-tools/lib/pipe-in.c +++ b/gettext-tools/lib/pipe-in.c @@ -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]); diff --git a/gettext-tools/lib/pipe-out.c b/gettext-tools/lib/pipe-out.c index d943b940e..304ed1ef8 100644 --- a/gettext-tools/lib/pipe-out.c +++ b/gettext-tools/lib/pipe-out.c @@ -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]); diff --git a/gettext-tools/lib/pipe.h b/gettext-tools/lib/pipe.h index 97e02ac08..de8f79047 100644 --- a/gettext-tools/lib/pipe.h +++ b/gettext-tools/lib/pipe.h @@ -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. diff --git a/gettext-tools/lib/wait-process.c b/gettext-tools/lib/wait-process.c index df257639f..3d9f91a11 100644 --- a/gettext-tools/lib/wait-process.c +++ b/gettext-tools/lib/wait-process.c @@ -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); } diff --git a/gettext-tools/lib/wait-process.h b/gettext-tools/lib/wait-process.h index 22440f410..5b31c766a 100644 --- a/gettext-tools/lib/wait-process.h +++ b/gettext-tools/lib/wait-process.h @@ -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 , 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 */