[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [autoconf] AmigaOS fork()
From: |
Rüdiger Kuhlmann |
Subject: |
Re: [autoconf] AmigaOS fork() |
Date: |
Thu, 31 May 2001 15:15:49 +0200 |
User-agent: |
Mutt/1.3.17i |
>--[Akim Demaille]--<address@hidden>
> I'll wait for some input from Alexandre, Jim or Paul on this one.
> | >--[Tim Van Holder]--<address@hidden>
> | Okay, what about this: It doesn't #define fork anymore, but HAVE_FORK if it
> | works. Then the program has to check this itself.
> I prefer HAVE_WORKING_FORK. Let's have HAVE_FOO keep its semantics.
Okay.
> We need some documentation, please.
Okay. Tell me if this is enough.
> | +#ifndef HAVE_FORK
> We avoid ifdef and ifndef, rather use
> #if !HAVE_FORK
Okay.
> AC_TRY_RUN is dead as far as Autoconf per se is concerned, please use
> AC_RUN_IFELSE. See AC_FUNC_GETPGRP for instance.
Okay.
> | + #if HAVE_UNISTD_H
> | + # include <unistd.h>
> | + #endif
> Hm, make sure you have the proper requirements to have this header
> test. Maybe it's already the case via AC_CHECK_FUNC, but I doubt it.
Okay.
> | + if (fork() < 0)
> | + exit (1);
> No way to actually *test* the feature?
There _is_ a test. Look carefully. If fork() "always" fails,
it is a stub. If the fork() succeeds, it is not.
> Nit picking: two \n between defs.
Okay.
> | + AC_DEFINE(HAVE_VFORK, 1, [Define if `vfork' works.])
> Again, HAVE_WORKING_VFORK seems more appropriate to me.
Okay.
> | AC_DEFUN([AC_FUNC_WAIT3],
> | -[AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
> | +[AC_REQUIRE([AC_FUNC_FORK])dnl
> | +AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
> | [...]
> | +#ifndef HAVE_FORK
> | +# define fork vfork
> | +#endif
> Instead of ``polluting'' all the tests, I'd suggest inserting this
> snippet in confdefs.h. But I'd like to hear comments about this.
No. This would be wrong. Then I'd better #define fork to be vfork. But vfork
is not necessarily a replacement for fork. But for the tests at hand, it is.
Another idea would be to add
#if HAVE_WORKING_FORK
#define forkvfork fork
#else
#if HAVE_WORKING_VFORK
#define forkvfork vfork
#else
#error Neither fork nor vfork available.
#endif
#endif
to confdefs.h and replace fork by forkvfork where appropriate. forkvfork in
the sense of prefer fork, but replace by vfork. Comments about that?
2001-05-31 Rüdiger Kuhlmann <address@hidden>
* acfunctions.m4: (AC_FUNC_FORK) New, check whether fork() isn't just
a stub and define HAVE_WORKING_FUNC if it works.
(AC_FUNC_GETPGRP, AC_FUNC_WAIT3) Use AC_FUNC_FORK and #define fork
to vfork if necessary.
(AC_FUN_VFORK) Similarly define HAVE_WORKING_VFORK.
* acspecific.m4: (AC_SYS_RESTARTABLE_SYSCALLS) dito.
* acfunctions: add HAVE_FORK.
* doc/autoconf.texi: Document AC_FUNC_FORK.
Index: acfunctions
===================================================================
RCS file: /cvs/autoconf/acfunctions,v
retrieving revision 1.13
diff -u -r1.13 acfunctions
--- acfunctions 2001/01/24 07:58:59 1.13
+++ acfunctions 2001/05/31 13:12:28
@@ -7,6 +7,7 @@
error AC_FUNC_ERROR_AT_LINE
error_at_line AC_FUNC_ERROR_AT_LINE
fnmatch AC_FUNC_FNMATCH
+fork AC_FUNC_FORK
fseeko AC_FUNC_FSEEKO
ftello AC_FUNC_FSEEKO
getgroups AC_FUNC_GETGROUPS
Index: acfunctions.m4
===================================================================
RCS file: /cvs/autoconf/acfunctions.m4,v
retrieving revision 1.33
diff -u -r1.33 acfunctions.m4
--- acfunctions.m4 2001/04/22 12:50:07 1.33
+++ acfunctions.m4 2001/05/31 13:12:31
@@ -599,7 +599,8 @@
# AC_FUNC_GETPGRP
# ---------------
AC_DEFUN([AC_FUNC_GETPGRP],
-[AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
+[AC_REQUIRE([AC_FUNC_FORK])dnl
+AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
/*
* If this system has a BSD-style getpgrp(),
@@ -609,6 +610,9 @@
*/
#include <stdio.h>
#include <sys/types.h>
+#if !HAVE_WORKING_FORK
+# define fork vfork
+#endif
int pid;
int pg1, pg2, pg3, pg4;
@@ -1442,6 +1446,42 @@
AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
+# AC_FUNC_FORK
+# -------------
+AC_DEFUN([AC_FUNC_FORK],
+ [AC_CHECK_FUNC(fork)
+ ac_cv_func_fork_works=$ac_cv_func_fork
+ if test "x$ac_cv_func_fork" = xyes; then
+ AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
+ [AC_CHECK_HEADERS(unistd.h)
+ AC_RUN_IFELSE([/* By Rüdiger Kuhlmann. */
+ #include <sys/types.h>
+ #if HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif
+ /* Some systems only have a dummy stub for fork() */
+ int main ()
+ {
+ if (fork() < 0)
+ exit (1);
+ exit (0);
+ }],
+ [ac_cv_func_fork_works=yes],
+ [ac_cv_func_fork_works=no],
+ [dnl
+ case "$host" in
+ *-*-amigaos* | *-*-msdosdjgpp*)
+ # Override, as these systems have only a dummy fork() stub
+ ac_cv_func_fork_works=no
+ ;;
+ esac])])
+ fi
+ if test "x$ac_cv_func_fork_works" = xyes; then
+ AC_DEFINE(HAVE_WORKING_FORK,1)
+ endif
+])# AC_FUNC_FORK
+
+
# AC_FUNC_VFORK
# -------------
AC_DEFUN([AC_FUNC_VFORK],
@@ -1547,6 +1587,8 @@
ac_cv_func_vfork_works=$ac_cv_func_vfork])])
if test "x$ac_cv_func_vfork_works" = xno; then
AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
+else
+ AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define if `vfork' works.])
fi
])# AC_FUNC_VFORK
@@ -1577,12 +1619,16 @@
# AC_FUNC_WAIT3
# -------------
AC_DEFUN([AC_FUNC_WAIT3],
-[AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
+[AC_REQUIRE([AC_FUNC_FORK])dnl
+AC_CACHE_CHECK(for wait3 that fills in rusage, ac_cv_func_wait3_rusage,
[AC_TRY_RUN(
[#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
+#if !HAVE_WORKING_FORK
+# define fork vfork
+#endif
/* HP-UX has wait3 but does not fill in rusage at all. */
int
main ()
Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.338
diff -u -r1.338 acspecific.m4
--- acspecific.m4 2001/04/15 16:20:30 1.338
+++ acspecific.m4 2001/05/31 13:12:35
@@ -495,6 +495,7 @@
# interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'.
AC_DEFUN([AC_SYS_RESTARTABLE_SYSCALLS],
[AC_REQUIRE([AC_HEADER_SYS_WAIT])dnl
+AC_REQUIRE([AC_FUNC_FORK])dnl
AC_CHECK_HEADERS(unistd.h)
AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
[AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -509,6 +510,9 @@
#endif
#if HAVE_SYS_WAIT_H
# include <sys/wait.h>
+#endif
+#if !HAVE_WORKING_FORK
+# define fork vfork
#endif
/* Some platforms explicitly require an extern "C" signal handler
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.452
diff -u -r1.452 autoconf.texi
--- doc/autoconf.texi 2001/05/31 07:32:27 1.452
+++ doc/autoconf.texi 2001/05/31 13:13:04
@@ -3226,6 +3226,13 @@
SunOS 5.4), define @code{HAVE_FNMATCH}.
@end defmac
address@hidden AC_FUNC_FORK
address@hidden FUNC_FORK
address@hidden HAVE_WORKING_FORK
+If a working @code{fork} is not found, define @code{HAVE_WORKING_FORK}. This
+macro only checks whether @code{fork} ist just a stub.
address@hidden defmac
+
@defmac AC_FUNC_FSEEKO
@maindex FUNC_FSEEKO
@cvindex _LARGEFILE_SOURCE
@@ -3459,14 +3466,16 @@
@defmac AC_FUNC_VFORK
@maindex FUNC_VFORK
@cvindex HAVE_VFORK_H
address@hidden HAVE_WORKING_VFORK
@cvindex vfork
If @file{vfork.h} is found, define @code{HAVE_VFORK_H}. If a working
address@hidden is not found, define @code{vfork} to be @code{fork}. 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.
address@hidden is not found, define @code{vfork} to be @code{fork},
+and define @code{HAVE_WORKING_VFORK}. 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.
@end defmac
@defmac AC_FUNC_VPRINTF
Yours, Rüdiger.
--
A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.
-- Mahatma Ghandi
- Re: AmigaOS fork(), (continued)
- Re: AmigaOS fork(), Russ Allbery, 2001/05/23
- Re: AmigaOS fork(), Tim Van Holder, 2001/05/24
- Re: [autoconf] AmigaOS fork(), Rüdiger Kuhlmann, 2001/05/24
- Re: [autoconf] AmigaOS fork(), Peter Eisentraut, 2001/05/24
- Re: [autoconf] AmigaOS fork(), Russ Allbery, 2001/05/24
- Re: [autoconf] AmigaOS fork(), Rüdiger Kuhlmann, 2001/05/27
- Re: [autoconf] AmigaOS fork(), Rüdiger Kuhlmann, 2001/05/31
- Re: AmigaOS fork(), Lars Hecking, 2001/05/31
- Re: [autoconf] AmigaOS fork(), Akim Demaille, 2001/05/31
- Re: [autoconf] AmigaOS fork(),
Rüdiger Kuhlmann <=
- Re: [autoconf] AmigaOS fork(), Tim Van Holder, 2001/05/31
- Re: [autoconf] AmigaOS fork(), Rüdiger Kuhlmann, 2001/05/31
- Re: [autoconf] AmigaOS fork(), Akim Demaille, 2001/05/31
- Re: [autoconf] AmigaOS fork(), Akim Demaille, 2001/05/31
- Re: [autoconf] AmigaOS fork(), Rüdiger Kuhlmann, 2001/05/31