[asterisk-commits] russell: branch 1.2 r46361 - in /branches/1.2: ./ apps/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Oct 27 10:36:07 MST 2006


Author: russell
Date: Fri Oct 27 12:36:07 2006
New Revision: 46361

URL: http://svn.digium.com/view/asterisk?rev=46361&view=rev
Log:
We should always be using _exit() after a fork() or vfork() instead of exit().
This is because exit() does some extra cleanup which in some implementations
of vfork(), for example, can actually modify the state of the parent process,
causing very weird bugs or crashes.  (issue #7971, Nick Gavrikov)

Modified:
    branches/1.2/apps/app_externalivr.c
    branches/1.2/asterisk.c
    branches/1.2/res/res_agi.c
    branches/1.2/res/res_musiconhold.c

Modified: branches/1.2/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_externalivr.c?rev=46361&r1=46360&r2=46361&view=diff
==============================================================================
--- branches/1.2/apps/app_externalivr.c (original)
+++ branches/1.2/apps/app_externalivr.c Fri Oct 27 12:36:07 2006
@@ -324,7 +324,7 @@
 			close(i);
 		execv(argv[0], argv);
 		fprintf(stderr, "Failed to execute '%s': %s\n", argv[0], strerror(errno));
-		exit(1);
+		_exit(1);
 	} else {
 		/* parent process */
 		int child_events_fd = child_stdin[1];

Modified: branches/1.2/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/asterisk.c?rev=46361&r1=46360&r2=46361&view=diff
==============================================================================
--- branches/1.2/asterisk.c (original)
+++ branches/1.2/asterisk.c Fri Oct 27 12:36:07 2006
@@ -449,7 +449,7 @@
 		for (x = STDERR_FILENO + 1; x < 4096; x++)
 			close(x);
 		execl("/bin/sh", "/bin/sh", "-c", s, NULL);
-		exit(1);
+		_exit(1);
 	} else if (pid > 0) {
 		for(;;) {
 			res = wait4(pid, &status, 0, &rusage);

Modified: branches/1.2/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/res/res_agi.c?rev=46361&r1=46360&r2=46361&view=diff
==============================================================================
--- branches/1.2/res/res_agi.c (original)
+++ branches/1.2/res/res_agi.c Fri Oct 27 12:36:07 2006
@@ -297,7 +297,7 @@
 		/* unblock important signal handlers */
 		if (sigfillset(&signal_set) || pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) {
 			ast_log(LOG_WARNING, "unable to unblock signals for AGI script: %s\n", strerror(errno));
-			exit(1);
+			_exit(1);
 		}
 
 		/* Close everything but stdin/out/error */
@@ -308,7 +308,7 @@
 		execv(script, argv);
 		/* Can't use ast_log since FD's are closed */
 		fprintf(stderr, "Failed to execute '%s': %s\n", script, strerror(errno));
-		exit(1);
+		_exit(1);
 	}
 	if (option_verbose > 2) 
 		ast_verbose(VERBOSE_PREFIX_3 "Launched AGI Script %s\n", script);

Modified: branches/1.2/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/res/res_musiconhold.c?rev=46361&r1=46360&r2=46361&view=diff
==============================================================================
--- branches/1.2/res/res_musiconhold.c (original)
+++ branches/1.2/res/res_musiconhold.c Fri Oct 27 12:36:07 2006
@@ -463,7 +463,7 @@
 		}
 		ast_log(LOG_WARNING, "Exec failed: %s\n", strerror(errno));
 		close(fds[1]);
-		exit(1);
+		_exit(1);
 	} else {
 		/* Parent */
 		close(fds[1]);



More information about the asterisk-commits mailing list