[svn-commits] tilghman: branch 1.4 r102323 - in /branches/1.4: ./ include/asterisk/ main/ u...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 4 15:06:10 CST 2008


Author: tilghman
Date: Mon Feb  4 15:06:09 2008
New Revision: 102323

URL: http://svn.digium.com/view/asterisk?view=rev&rev=102323
Log:
Cross-platform fix:  OS X now deprecates the use of the daemon(3) API.
(closes issue #11908)
 Reported by: oej
 Patches: 
       20080204__bug11908.diff.txt uploaded by Corydon76 (license 14)
 Tested by: Corydon76

Modified:
    branches/1.4/configure
    branches/1.4/configure.ac
    branches/1.4/include/asterisk/autoconfig.h.in
    branches/1.4/main/asterisk.c
    branches/1.4/utils/muted.c

Modified: branches/1.4/configure.ac
URL: http://svn.digium.com/view/asterisk/branches/1.4/configure.ac?view=diff&rev=102323&r1=102322&r2=102323
==============================================================================
--- branches/1.4/configure.ac (original)
+++ branches/1.4/configure.ac Mon Feb  4 15:06:09 2008
@@ -1090,6 +1090,8 @@
 				   ])
 AC_SUBST(PBX_IXJUSER)
 
+AC_CHECK_FILE(/sbin/launchd, AC_DEFINE([HAVE_SBIN_LAUNCHD], 1, [Define to 1 if your system has /sbin/launchd.]))
+
 PBX_GTK=0
 AC_CHECK_TOOL(GTKCONFIG, gtk-config, No)
 if test ! "x${GTKCONFIG}" = xNo; then

Modified: branches/1.4/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/autoconfig.h.in?view=diff&rev=102323&r1=102322&r2=102323
==============================================================================
--- branches/1.4/include/asterisk/autoconfig.h.in (original)
+++ branches/1.4/include/asterisk/autoconfig.h.in Mon Feb  4 15:06:09 2008
@@ -319,6 +319,9 @@
 /* Define to 1 if your system has a dynamic linker that supports RTLD_NOLOAD.
    */
 #undef HAVE_RTLD_NOLOAD
+
+/* Define to 1 if your system has /sbin/launchd. */
+#undef HAVE_SBIN_LAUNCHD
 
 /* Define to 1 if you have the `select' function. */
 #undef HAVE_SELECT
@@ -638,9 +641,6 @@
 #ifndef _POSIX_PTHREAD_SEMANTICS
 # undef _POSIX_PTHREAD_SEMANTICS
 #endif
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
 
 /* Define like PROTOTYPES; this can be used by system headers. */
 #undef __PROTOTYPES

Modified: branches/1.4/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/asterisk.c?view=diff&rev=102323&r1=102322&r2=102323
==============================================================================
--- branches/1.4/main/asterisk.c (original)
+++ branches/1.4/main/asterisk.c Mon Feb  4 15:06:09 2008
@@ -2844,6 +2844,7 @@
 
 #if HAVE_WORKING_FORK
 	if (ast_opt_always_fork || !ast_opt_no_fork) {
+#ifndef HAVE_SBIN_LAUNCHD
 		daemon(1, 0);
 		ast_mainpid = getpid();
 		/* Blindly re-write pid file since we are forking */
@@ -2854,6 +2855,9 @@
 			fclose(f);
 		} else
 			ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
+#else
+		ast_log(LOG_WARNING, "Mac OS X detected.  Use '/sbin/launchd -d' to launch with the nofork option.\n");
+#endif
 	}
 #endif
 

Modified: branches/1.4/utils/muted.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/utils/muted.c?view=diff&rev=102323&r1=102322&r2=102323
==============================================================================
--- branches/1.4/utils/muted.c (original)
+++ branches/1.4/utils/muted.c Mon Feb  4 15:06:09 2008
@@ -680,8 +680,14 @@
 		fclose(astf);
 		exit(1);
 	}
-	if (needfork)
+	if (needfork) {
+#ifndef HAVE_SBIN_LAUNCHD
 		daemon(0,0);
+#else
+		fprintf(stderr, "Mac OS X detected.  Use 'launchd -d muted -f' to launch.\n");
+		exit(1);
+#endif
+	}
 	for(;;) {
 		if (wait_event()) {
 			fclose(astf);




More information about the svn-commits mailing list