[asterisk-commits] kpfleming: trunk r40790 - in /trunk: ./ main/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Aug 21 13:12:19 MST 2006


Author: kpfleming
Date: Mon Aug 21 15:12:18 2006
New Revision: 40790

URL: http://svn.digium.com/view/asterisk?rev=40790&view=rev
Log:
use a customized configure macro to tell the script that uCLinux does not have fork() that works
drop all startup options and code related to forking if it is not available

Modified:
    trunk/acinclude.m4
    trunk/configure
    trunk/configure.ac
    trunk/main/asterisk.c

Modified: trunk/acinclude.m4
URL: http://svn.digium.com/view/asterisk/trunk/acinclude.m4?rev=40790&r1=40789&r2=40790&view=diff
==============================================================================
--- trunk/acinclude.m4 (original)
+++ trunk/acinclude.m4 Mon Aug 21 15:12:18 2006
@@ -115,3 +115,63 @@
 fi
 AC_SUBST([GNU_MAKE])
 ])
+
+# AST_FUNC_FORK
+# -------------
+AN_FUNCTION([fork],  [AST_FUNC_FORK])
+AN_FUNCTION([vfork], [AST_FUNC_FORK])
+AC_DEFUN([AST_FUNC_FORK],
+[AC_REQUIRE([AC_TYPE_PID_T])dnl
+AC_CHECK_HEADERS(vfork.h)
+AC_CHECK_FUNCS(fork vfork)
+if test "x$ac_cv_func_fork" = xyes; then
+  _AST_FUNC_FORK
+else
+  ac_cv_func_fork_works=$ac_cv_func_fork
+fi
+if test "x$ac_cv_func_fork_works" = xcross; then
+  case $host in
+    *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
+      # Override, as these systems have only a dummy fork() stub
+      ac_cv_func_fork_works=no
+      ;;
+    *)
+      ac_cv_func_fork_works=yes
+      ;;
+  esac
+  AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
+fi
+ac_cv_func_vfork_works=$ac_cv_func_vfork
+if test "x$ac_cv_func_vfork" = xyes; then
+  _AC_FUNC_VFORK
+fi;
+if test "x$ac_cv_func_fork_works" = xcross; then
+  ac_cv_func_vfork_works=$ac_cv_func_vfork
+  AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
+fi
+
+if test "x$ac_cv_func_vfork_works" = xyes; then
+  AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
+else
+  AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
+fi
+if test "x$ac_cv_func_fork_works" = xyes; then
+  AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
+fi
+])# AST_FUNC_FORK
+
+
+# _AST_FUNC_FORK
+# -------------
+AC_DEFUN([_AST_FUNC_FORK],
+  [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
+    [AC_RUN_IFELSE(
+      [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+	[
+	  /* By Ruediger Kuhlmann. */
+	  return fork () < 0;
+	])],
+      [ac_cv_func_fork_works=yes],
+      [ac_cv_func_fork_works=no],
+      [ac_cv_func_fork_works=cross])])]
+)# _AST_FUNC_FORK

Modified: trunk/configure
URL: http://svn.digium.com/view/asterisk/trunk/configure?rev=40790&r1=40789&r2=40790&view=diff
==============================================================================
--- trunk/configure (original)
+++ trunk/configure Mon Aug 21 15:12:18 2006
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 40597 .
+# From configure.ac Revision: 40722 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.60.
 #
@@ -10219,7 +10219,7 @@
 fi
 if test "x$ac_cv_func_fork_works" = xcross; then
   case $host in
-    *-*-amigaos* | *-*-msdosdjgpp*)
+    *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
       # Override, as these systems have only a dummy fork() stub
       ac_cv_func_fork_works=no
       ;;

Modified: trunk/configure.ac
URL: http://svn.digium.com/view/asterisk/trunk/configure.ac?rev=40790&r1=40789&r2=40790&view=diff
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon Aug 21 15:12:18 2006
@@ -198,7 +198,7 @@
 AC_FUNC_CHOWN
 AC_FUNC_CLOSEDIR_VOID
 AC_FUNC_ERROR_AT_LINE
-AC_FUNC_FORK
+AST_FUNC_FORK
 AC_FUNC_FSEEKO
 AC_PROG_GCC_TRADITIONAL
 # XXX: these are commented out until we determine whether it matters if our malloc()

Modified: trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/main/asterisk.c?rev=40790&r1=40789&r2=40790&view=diff
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Mon Aug 21 15:12:18 2006
@@ -647,7 +647,8 @@
 	struct rusage rusage;
 	int status;
 
-	ast_replace_sigchld();
+#if HAVE_WORKING_FORK
+    	ast_replace_sigchld();
 
 	pid = fork();
 
@@ -674,6 +675,9 @@
 	}
 
 	ast_unreplace_sigchld();
+#else
+	res = -1;
+#endif
 
 	return res;
 }
@@ -2101,7 +2105,10 @@
 	printf("   -U <user>       Run as a user other than the caller\n");
 	printf("   -c              Provide console CLI\n");
 	printf("   -d              Enable extra debugging\n");
+#if HAVE_WORKING_FORK
 	printf("   -f              Do not fork\n");
+	printf("   -F              Always fork\n");
+#endif
 	printf("   -g              Dump core in case of a crash\n");
 	printf("   -h              This help screen\n");
 	printf("   -i              Initialize crypto keys at startup\n");
@@ -2209,12 +2216,14 @@
 			if (sscanf(v->value, "%d", &option_debug) != 1) {
 				option_debug = ast_true(v->value);
 			}
+#if HAVE_WORKING_FORK
 		/* Disable forking (-f at startup) */
 		} else if (!strcasecmp(v->name, "nofork")) {
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);
 		/* Always fork, even if verbose or debug are enabled (-F at startup) */
 		} else if (!strcasecmp(v->name, "alwaysfork")) {
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);
+#endif
 		/* Run quietly (-q at startup ) */
 		} else if (!strcasecmp(v->name, "quiet")) {
 			ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
@@ -2326,18 +2335,20 @@
 	/* Check for options */
 	while ((c = getopt(argc, argv, "mtThfdvVqprRgciInx:U:G:C:L:M:")) != -1) {
 		switch (c) {
+#if HAVE_WORKING_FORK
 		case 'F':
 			ast_set_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
 			break;
+		case 'f':
+			ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
+			break;
+#endif
 		case 'd':
 			option_debug++;
 			ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
 			break;
 		case 'c':
 			ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
-			break;
-		case 'f':
-			ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
 			break;
 		case 'n':
 			ast_set_flag(&ast_options, AST_OPT_FLAG_NO_COLOR);
@@ -2560,6 +2571,7 @@
 	} else
 		ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
 
+#if HAVE_WORKING_FORK
 	if (ast_opt_always_fork || !ast_opt_no_fork) {
 		daemon(0, 0);
 		ast_mainpid = getpid();
@@ -2572,6 +2584,7 @@
 		} else
 			ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
 	}
+#endif
 
 	/* Test recursive mutex locking. */
 	if (test_for_thread_safety())
@@ -2719,9 +2732,11 @@
 
 	}
 	/* Do nothing */
-	for(;;)  {	/* apparently needed for the MACos */
+	for (;;) {	/* apparently needed for Mac OS X */
 		struct pollfd p = { -1 /* no descriptor */, 0, 0 };
+
 		poll(&p, 0, -1);
 	}
+
 	return 0;
 }



More information about the asterisk-commits mailing list