[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] AC_FUNC_VFORK: check for Solaris 2.4 signal-handling bug
From: |
Paul Eggert |
Subject: |
[PATCH] AC_FUNC_VFORK: check for Solaris 2.4 signal-handling bug |
Date: |
Sun, 16 Sep 2012 16:43:16 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 |
* NEWS:
* doc/autoconf.texi (Particular Functions): Document this.
* lib/autoconf/functions.m4 (_AC_FUNC_VFORK): Check for the bug.
---
NEWS | 7 ++++++-
doc/autoconf.texi | 5 +----
lib/autoconf/functions.m4 | 24 ++++++++++++++++++++----
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/NEWS b/NEWS
index 0fda46e..7c1e77e 100644
--- a/NEWS
+++ b/NEWS
@@ -5,13 +5,18 @@ GNU Autoconf NEWS - User visible changes.
** The use of the long-deprecated name 'configure.in' for the autoconf
input file now elicits a warning in the 'obsolete' category.
-** MACROS
+** Macros
- New macro AC_PROG_CC_C11.
- AC_PROG_CC_STDC now prefers C11 if available, falling back on C99
and then on C89 as before.
+- AC_FUNC_VFORK now checks for the signal-handling bug in Solaris 2.4 'vfork'.
+ Formerly, it ignored this bug, so that Emacs could use some tricky
+ code on that platform. Solaris 2.4 has not been supported since
+ 2003 and nowadays it's better to omit that old trick.
+
* Noteworthy changes in release 2.69 (2012-04-24) [stable]
** Autoconf now requires perl 5.6 or better (but generated configure
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 7b8bfd5..611b675 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -4993,10 +4993,7 @@ If @file{vfork.h} is found, define @code{HAVE_VFORK_H}.
If a working
define @code{vfork} to be @code{fork} for backward compatibility with
previous versions of @command{autoconf}. This macro checks for several known
errors in implementations of @code{vfork} and considers the system to not
-have a working @code{vfork} if it detects any of them. It is not considered
-to be an implementation error if a child's invocation of @code{signal}
-modifies the parent's signal handler, since child processes rarely change
-their signal handlers.
+have a working @code{vfork} if it detects any of them.
Since this macro defines @code{vfork} only for backward compatibility with
previous versions of @command{autoconf} you're encouraged to define it
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 5987a0c..782393b 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -1894,10 +1894,18 @@ AC_DEFUN([_AC_FUNC_VFORK],
[AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
]AC_INCLUDES_DEFAULT[
+#include <signal.h>
#include <sys/wait.h>
#ifdef HAVE_VFORK_H
# include <vfork.h>
#endif
+
+static void
+do_nothing (int sig)
+{
+ (void) sig;
+}
+
/* On some sparc systems, changes by the child to local and incoming
argument registers are propagated back to the parent. The compiler
is told about this with #include <vfork.h>, but some compilers
@@ -1905,11 +1913,7 @@ AC_DEFUN([_AC_FUNC_VFORK],
static variable whose address is put into a register that is
clobbered by the vfork. */
static void
-#ifdef __cplusplus
sparc_address_test (int arg)
-# else
-sparc_address_test (arg) int arg;
-#endif
{
static pid_t child;
if (!child) {
@@ -1934,6 +1938,11 @@ main ()
sparc_address_test (0);
+ /* On Solaris 2.4, changes by the child to the signal handler
+ also munge signal handlers in the parent. To detect this,
+ start by putting the parent's handler in a known state. */
+ signal (SIGTERM, SIG_DFL);
+
child = vfork ();
if (child == 0) {
@@ -1955,6 +1964,10 @@ main ()
|| p != p5 || p != p6 || p != p7)
_exit(1);
+ /* Alter the child's signal handler. */
+ if (signal (SIGTERM, do_nothing) != SIG_DFL)
+ _exit(1);
+
/* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
from child file descriptors. If the child closes a descriptor
before it execs or exits, this munges the parent's descriptor
@@ -1970,6 +1983,9 @@ main ()
/* Was there some problem with vforking? */
child < 0
+ /* Did the child munge the parent's signal handler? */
+ || signal (SIGTERM, SIG_DFL) != SIG_DFL
+
/* Did the child fail? (This shouldn't happen.) */
|| status
--
1.7.11.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] AC_FUNC_VFORK: check for Solaris 2.4 signal-handling bug,
Paul Eggert <=