[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] wait-process merge
From: |
Bruno Haible |
Subject: |
[Bug-gnulib] wait-process merge |
Date: |
Tue, 20 Jan 2004 17:48:53 +0100 |
User-agent: |
KMail/1.5 |
Hi,
I've committed this update, from GNU gettext.
wait_subprocess now handles SIGPIPE if necessary.
Doesn't attempt use waitid() any more - waitid() does not work on those
platforms that have it.
2003-12-28 Bruno Haible <address@hidden>
* wait-process.c (wait_subprocess): Add ignore_sigpipe argument.
* wait-process.c (wait_subprocess): Likewise. Handle SIGPIPE specially.
* wait-process.c (cleanup_slaves): Use ANSI C declaration.
* wait-process.c: On Windows, include windows.h. Needed on mingw.
* wait-process.c (wait_process): Disable the 2003-10-31 waitid() patch.
*** wait-process.h 20 Oct 2003 11:03:54 -0000 1.1
--- wait-process.h 20 Jan 2004 16:45:33 -0000
***************
*** 36,44 ****
/* 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. */
extern int wait_subprocess (pid_t child, const char *progname,
! bool null_stderr,
bool slave_process, bool exit_on_error);
/* Register a subprocess as being a slave process. This means that the
--- 36,58 ----
/* 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.
! 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 ignore_sigpipe, bool null_stderr,
bool slave_process, bool exit_on_error);
/* Register a subprocess as being a slave process. This means that the
*** wait-process.c 3 Nov 2003 20:47:02 -0000 1.2
--- wait-process.c 20 Jan 2004 16:45:33 -0000
***************
*** 103,108 ****
--- 103,111 ----
#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,146 ****
/* The cleanup action. It gets called asynchronously. */
static void
! cleanup_slaves ()
{
for (;;)
{
--- 143,149 ----
/* The cleanup action. It gets called asynchronously. */
static void
! cleanup_slaves (void)
{
for (;;)
{
***************
*** 249,258 ****
return 127. */
int
wait_subprocess (pid_t child, const char *progname,
! bool null_stderr,
bool slave_process, bool exit_on_error)
{
! #if HAVE_WAITID && defined WNOWAIT
/* 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
--- 252,264 ----
return 127. */
int
wait_subprocess (pid_t child, const char *progname,
! bool ignore_sigpipe, bool null_stderr,
bool slave_process, bool exit_on_error)
{
! #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,318 ****
--- 319,328 ----
{
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,381 ****
--- 386,395 ----
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"),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-gnulib] wait-process merge,
Bruno Haible <=