]> 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:39:31 +0000 (17:39 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 27 Oct 2006 17:39:31 +0000 (17:39 +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.4@46363 65c4cc65-6c06-0410-ace0-fbb531ad65f3

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

index 7929a02382e8730403fd5749d74bd0752130d993..a42dd95512f1d5e36e3922ad9c95a3949710a4b3 100644 (file)
@@ -322,7 +322,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 941d2112982d4c697bceb5e7e81c642fafa41f00..7b7b11ae77b0c1193471e89ff6ba1eb6dc0e5659 100644 (file)
@@ -715,7 +715,7 @@ int ast_safe_system(const char *s)
                        close(x);
 #endif
                execl("/bin/sh", "/bin/sh", "-c", s, (char *) NULL);
-               exit(1);
+               _exit(1);
        } else if (pid > 0) {
                for(;;) {
                        res = wait4(pid, &status, 0, &rusage);
index de9fd315120e4d3c7ec8d95fc0d59d09102dabf7..7a9677c6c0c78613130b8acd595cccb58b1bda7f 100644 (file)
@@ -318,7 +318,7 @@ static enum agi_result launch_script(char *script, char *argv[], int *fds, int *
                /* 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 */
@@ -330,7 +330,7 @@ static enum agi_result launch_script(char *script, char *argv[], int *fds, int *
                /* Can't use ast_log since FD's are closed */
                fprintf(stdout, "verbose \"Failed to execute '%s': %s\" 2\n", script, strerror(errno));
                fflush(stdout);
-               exit(1);
+               _exit(1);
        }
        if (option_verbose > 2) 
                ast_verbose(VERBOSE_PREFIX_3 "Launched AGI Script %s\n", script);
index a4debac8f30e67cd111d22fb86da8f46e9cc8639..d6832009d800cb58419898a725e32c1d80fa46e8 100644 (file)
@@ -461,7 +461,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]);