+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.
#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)
/* The cleanup action. It gets called asynchronously. */
static void
-cleanup_slaves ()
+cleanup_slaves (void)
{
for (;;)
{
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
{
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"),
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"),
/* 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