]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
We should always be using _exit() after a fork() or vfork() instead of exit().
authorRussell Bryant <russell@russellbryant.com>
Fri, 27 Oct 2006 17:36:07 +0000 (17:36 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 27 Oct 2006 17:36:07 +0000 (17:36 +0000)
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)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@46361 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_externalivr.c
asterisk.c
res/res_agi.c
res/res_musiconhold.c

index 5d27f9b3cb2b032e8d065821fa723f43d23afb94..fc5f34082f1c242e5cbc1740efeb818e32ed2944 100644 (file)
@@ -324,7 +324,7 @@ static int app_exec(struct ast_channel *chan, void *data)
                        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];
index 9cfdc565d58e597b25de2bfaa56b9595f7ef3da5..bc15eb5c7d569c1403b24fcd54538f8e070b48b3 100644 (file)
@@ -449,7 +449,7 @@ int ast_safe_system(const char *s)
                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);
index de4c7be39378527281c0f2b146a5c12e87583e12..56ab7bf42288b1cc638e29d477d69fdb96349ecc 100644 (file)
@@ -297,7 +297,7 @@ static int launch_script(char *script, char *argv[], int *fds, int *efd, int *op
                /* 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 @@ static int launch_script(char *script, char *argv[], int *fds, int *efd, int *op
                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);
index b005cd765a86009b7a8a756bf7c7a1cd283dd79e..9972889f89be90663e435b83dcecb66aa90942a0 100644 (file)
@@ -463,7 +463,7 @@ static int spawn_mp3(struct mohclass *class)
                }
                ast_log(LOG_WARNING, "Exec failed: %s\n", strerror(errno));
                close(fds[1]);
-               exit(1);
+               _exit(1);
        } else {
                /* Parent */
                close(fds[1]);