From: Bruno Haible Date: Tue, 20 Jan 2004 16:47:31 +0000 (+0000) Subject: Update from gettext. X-Git-Tag: cvs-readonly~4259 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=fac736731193084993688df404fd72a0afe560c4;p=gnulib.git Update from gettext. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 4eb66fc40..ea8a674cc 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,20 @@ +2003-12-28 Bruno Haible + + * wait-process.c (wait_subprocess): Add ignore_sigpipe argument. + * wait-process.c (wait_subprocess): Likewise. Handle SIGPIPE specially. + +2003-11-28 Bruno Haible + + * wait-process.c (cleanup_slaves): Use ANSI C declaration. + +2003-11-27 Bruno Haible + + * wait-process.c: On Windows, include windows.h. Needed on mingw. + +2003-11-17 Bruno Haible + + * wait-process.c (wait_process): Disable the 2003-10-31 waitid() patch. + 2003-11-24 Bruno Haible * xallocsa.h: New file, from GNU gettext. diff --git a/lib/wait-process.c b/lib/wait-process.c index 26a889ca4..0af9a1833 100644 --- a/lib/wait-process.c +++ b/lib/wait-process.c @@ -103,6 +103,9 @@ #if defined _MSC_VER || defined __MINGW32__ +#define WIN32_LEAN_AND_MEAN +#include + /* 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"), diff --git a/lib/wait-process.h b/lib/wait-process.h index 220014263..0d117f3b1 100644 --- a/lib/wait-process.h +++ b/lib/wait-process.h @@ -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