+2002-01-05 Bruno Haible <bruno@clisp.org>
+
+ * wait-process.c (WIFSIGNALED): Make it return false when WIFSTOPPED
+ returns true.
+ (wait_subprocess): Use WIFSIGNALED instead of WCOREDUMP || WTERMSIG.
+ On AIX and OSF/1, WTERMSIG has a negative value if !WIFSIGNALED. And
+ WCOREDUMP is a BSDism, not POSIX.
+
2001-12-23 Bruno Haible <bruno@clisp.org>
* xsetenv.h: New file.
/* Waiting for a subprocess to finish.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002 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
# ifndef WEXITSTATUS
# define WEXITSTATUS(x) ((x).w_retcode)
# endif
-# ifndef WIFSIGNALED
-# define WIFSIGNALED(x) (WTERMSIG(x) != 0)
-# endif
-# ifndef WIFEXITED
-# define WIFEXITED(x) (WTERMSIG(x) == 0)
-# endif
-# ifndef WIFSTOPPED
-# define WIFSTOPPED(x) (WTERMSIG(x) == 0x7f)
-# endif
#else
# define WAIT_T int
# ifndef WTERMSIG
# ifndef WEXITSTATUS
# define WEXITSTATUS(x) (((x) >> 8) & 0xff)
# endif
-# ifndef WIFSIGNALED
-# define WIFSIGNALED(x) (WTERMSIG (x) != 0)
-# endif
-# ifndef WIFEXITED
-# define WIFEXITED(x) (WTERMSIG (x) == 0)
-# endif
-# ifndef WIFSTOPPED
-# define WIFSTOPPED(x) (WTERMSIG(x) == 0x7f)
-# endif
#endif
+/* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
+ is true. */
+#ifndef WIFSIGNALED
+# define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(x) (WTERMSIG (x) == 0)
+#endif
+#ifndef WIFSTOPPED
+# define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f)
+#endif
+/* Note that portable applications may access
+ WTERMSIG(x) only if WIFSIGNALED(x) is true, and
+ WEXITSTATUS(x) only if WIFEXITED(x) is true. */
#include "error.h"
#include "exit.h"
return 127;
}
+ /* One of WIFSIGNALED (status), WIFEXITED (status), WIFSTOPPED (status)
+ must always be true. Loop until the program terminates. */
if (!WIFSTOPPED (status))
break;
}
- if (WCOREDUMP (status) || WTERMSIG (status) != 0)
+ if (WIFSIGNALED (status))
{
if (exit_on_error)
- error (EXIT_FAILURE, 0, _("%s subprocess got fatal signal"), progname);
+ error (EXIT_FAILURE, 0, _("%s subprocess got fatal signal %d"),
+ progname, (int) WTERMSIG (status));
else
return 127;
}