Skip to content
Snippets Groups Projects
Commit a394f4ad authored by Kevin P. Fleming's avatar Kevin P. Fleming
Browse files

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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40790 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent ca0a1d38
No related branches found
No related tags found
No related merge requests found
...@@ -115,3 +115,63 @@ if test "x$GNU_MAKE" = "xNot Found" ; then ...@@ -115,3 +115,63 @@ if test "x$GNU_MAKE" = "xNot Found" ; then
fi fi
AC_SUBST([GNU_MAKE]) 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
#! /bin/sh #! /bin/sh
# From configure.ac Revision: 40597 . # From configure.ac Revision: 40722 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.60. # Generated by GNU Autoconf 2.60.
# #
...@@ -10219,7 +10219,7 @@ else ...@@ -10219,7 +10219,7 @@ else
fi fi
if test "x$ac_cv_func_fork_works" = xcross; then if test "x$ac_cv_func_fork_works" = xcross; then
case $host in case $host in
*-*-amigaos* | *-*-msdosdjgpp*) *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
# Override, as these systems have only a dummy fork() stub # Override, as these systems have only a dummy fork() stub
ac_cv_func_fork_works=no ac_cv_func_fork_works=no
;; ;;
......
...@@ -198,7 +198,7 @@ AC_CHECK_TYPES([ptrdiff_t]) ...@@ -198,7 +198,7 @@ AC_CHECK_TYPES([ptrdiff_t])
AC_FUNC_CHOWN AC_FUNC_CHOWN
AC_FUNC_CLOSEDIR_VOID AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK AST_FUNC_FORK
AC_FUNC_FSEEKO AC_FUNC_FSEEKO
AC_PROG_GCC_TRADITIONAL AC_PROG_GCC_TRADITIONAL
# XXX: these are commented out until we determine whether it matters if our malloc() # XXX: these are commented out until we determine whether it matters if our malloc()
......
...@@ -647,7 +647,8 @@ int ast_safe_system(const char *s) ...@@ -647,7 +647,8 @@ int ast_safe_system(const char *s)
struct rusage rusage; struct rusage rusage;
int status; int status;
ast_replace_sigchld(); #if HAVE_WORKING_FORK
ast_replace_sigchld();
pid = fork(); pid = fork();
...@@ -674,6 +675,9 @@ int ast_safe_system(const char *s) ...@@ -674,6 +675,9 @@ int ast_safe_system(const char *s)
} }
ast_unreplace_sigchld(); ast_unreplace_sigchld();
#else
res = -1;
#endif
return res; return res;
} }
...@@ -2101,7 +2105,10 @@ static int show_cli_help(void) { ...@@ -2101,7 +2105,10 @@ static int show_cli_help(void) {
printf(" -U <user> Run as a user other than the caller\n"); printf(" -U <user> Run as a user other than the caller\n");
printf(" -c Provide console CLI\n"); printf(" -c Provide console CLI\n");
printf(" -d Enable extra debugging\n"); printf(" -d Enable extra debugging\n");
#if HAVE_WORKING_FORK
printf(" -f Do not fork\n"); printf(" -f Do not fork\n");
printf(" -F Always fork\n");
#endif
printf(" -g Dump core in case of a crash\n"); printf(" -g Dump core in case of a crash\n");
printf(" -h This help screen\n"); printf(" -h This help screen\n");
printf(" -i Initialize crypto keys at startup\n"); printf(" -i Initialize crypto keys at startup\n");
...@@ -2209,12 +2216,14 @@ static void ast_readconfig(void) ...@@ -2209,12 +2216,14 @@ static void ast_readconfig(void)
if (sscanf(v->value, "%d", &option_debug) != 1) { if (sscanf(v->value, "%d", &option_debug) != 1) {
option_debug = ast_true(v->value); option_debug = ast_true(v->value);
} }
#if HAVE_WORKING_FORK
/* Disable forking (-f at startup) */ /* Disable forking (-f at startup) */
} else if (!strcasecmp(v->name, "nofork")) { } else if (!strcasecmp(v->name, "nofork")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK); 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) */ /* Always fork, even if verbose or debug are enabled (-F at startup) */
} else if (!strcasecmp(v->name, "alwaysfork")) { } else if (!strcasecmp(v->name, "alwaysfork")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK); ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);
#endif
/* Run quietly (-q at startup ) */ /* Run quietly (-q at startup ) */
} else if (!strcasecmp(v->name, "quiet")) { } else if (!strcasecmp(v->name, "quiet")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET); ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
...@@ -2326,9 +2335,14 @@ int main(int argc, char *argv[]) ...@@ -2326,9 +2335,14 @@ int main(int argc, char *argv[])
/* Check for options */ /* Check for options */
while ((c = getopt(argc, argv, "mtThfdvVqprRgciInx:U:G:C:L:M:")) != -1) { while ((c = getopt(argc, argv, "mtThfdvVqprRgciInx:U:G:C:L:M:")) != -1) {
switch (c) { switch (c) {
#if HAVE_WORKING_FORK
case 'F': case 'F':
ast_set_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK); ast_set_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
break; break;
case 'f':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
break;
#endif
case 'd': case 'd':
option_debug++; option_debug++;
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK); ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
...@@ -2336,9 +2350,6 @@ int main(int argc, char *argv[]) ...@@ -2336,9 +2350,6 @@ int main(int argc, char *argv[])
case 'c': case 'c':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE); ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK | AST_OPT_FLAG_CONSOLE);
break; break;
case 'f':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
break;
case 'n': case 'n':
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_COLOR); ast_set_flag(&ast_options, AST_OPT_FLAG_NO_COLOR);
break; break;
...@@ -2560,6 +2571,7 @@ int main(int argc, char *argv[]) ...@@ -2560,6 +2571,7 @@ int main(int argc, char *argv[])
} else } else
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno)); 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) { if (ast_opt_always_fork || !ast_opt_no_fork) {
daemon(0, 0); daemon(0, 0);
ast_mainpid = getpid(); ast_mainpid = getpid();
...@@ -2572,6 +2584,7 @@ int main(int argc, char *argv[]) ...@@ -2572,6 +2584,7 @@ int main(int argc, char *argv[])
} else } else
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno)); ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
} }
#endif
/* Test recursive mutex locking. */ /* Test recursive mutex locking. */
if (test_for_thread_safety()) if (test_for_thread_safety())
...@@ -2719,9 +2732,11 @@ int main(int argc, char *argv[]) ...@@ -2719,9 +2732,11 @@ int main(int argc, char *argv[])
} }
/* Do nothing */ /* Do nothing */
for(;;) { /* apparently needed for the MACos */ for (;;) { /* apparently needed for Mac OS X */
struct pollfd p = { -1 /* no descriptor */, 0, 0 }; struct pollfd p = { -1 /* no descriptor */, 0, 0 };
poll(&p, 0, -1); poll(&p, 0, -1);
} }
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment