projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* doc/headers/assert.texi (assert.h): Document assert module use.
[gnulib.git]
/
lib
/
wait-process.c
diff --git
a/lib/wait-process.c
b/lib/wait-process.c
index
26a889c
..
268be32
100644
(file)
--- a/
lib/wait-process.c
+++ b/
lib/wait-process.c
@@
-1,5
+1,5
@@
/* Waiting for a subprocess to finish.
/* Waiting for a subprocess to finish.
- Copyright (C) 2001-2003 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003
, 2005-2007
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
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
@@
-14,12
+14,10
@@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
- Inc., 5
9 Temple Place - Suite 330, Boston, MA 02111-1307
, USA. */
+ Inc., 5
1 Franklin Street, Fifth Floor, Boston, MA 02110-1301
, USA. */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <config.h>
/* Specification. */
#include "wait-process.h"
/* Specification. */
#include "wait-process.h"
@@
-91,7
+89,6
@@
#endif
#include "error.h"
#endif
#include "error.h"
-#include "exit.h"
#include "fatal-signal.h"
#include "xalloc.h"
#include "gettext.h"
#include "fatal-signal.h"
#include "xalloc.h"
#include "gettext.h"
@@
-103,6
+100,9
@@
#if defined _MSC_VER || defined __MINGW32__
#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 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
+140,7
@@
static size_t slaves_allocated = SIZEOF (static_slaves);
/* The cleanup action. It gets called asynchronously. */
static void
/* The cleanup action. It gets called asynchronously. */
static void
-cleanup_slaves ()
+cleanup_slaves (
void
)
{
for (;;)
{
{
for (;;)
{
@@
-202,6
+202,7
@@
register_slave_subprocess (pid_t child)
slaves_entry_t *old_slaves = slaves;
size_t new_slaves_allocated = 2 * slaves_allocated;
slaves_entry_t *new_slaves =
slaves_entry_t *old_slaves = slaves;
size_t new_slaves_allocated = 2 * slaves_allocated;
slaves_entry_t *new_slaves =
+ (slaves_entry_t *)
malloc (new_slaves_allocated * sizeof (slaves_entry_t));
if (new_slaves == NULL)
{
malloc (new_slaves_allocated * sizeof (slaves_entry_t));
if (new_slaves == NULL)
{
@@
-249,10
+250,13
@@
unregister_slave_subprocess (pid_t child)
return 127. */
int
wait_subprocess (pid_t child, const char *progname,
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)
{
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
/* 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
+317,10
@@
wait_subprocess (pid_t child, const char *progname,
{
case CLD_KILLED:
case CLD_DUMPED:
{
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 (exit_on_error || !null_stderr)
error (exit_on_error ? EXIT_FAILURE : 0, 0,
_("%s subprocess got fatal signal %d"),
@@
-376,6
+384,10
@@
wait_subprocess (pid_t child, const char *progname,
if (WIFSIGNALED (status))
{
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"),
if (exit_on_error || !null_stderr)
error (exit_on_error ? EXIT_FAILURE : 0, 0,
_("%s subprocess got fatal signal %d"),