All pastes #58858 Raw Edit

Someone

public text v1 · immutable
#58858 ·published 2006-05-25 17:26 UTC
rendered paste body
Index: res/res_agi.c
===================================================================
--- res/res_agi.c       (revision 30272)
+++ res/res_agi.c       (working copy)
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/wait.h>

 #include "asterisk.h"

@@ -1781,7 +1782,7 @@
        return 0;
 }
 #define RETRY  3
-static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid, int dead)
+static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid, int *status, int dead)
 {
        struct ast_channel *c;
        int outfd;
@@ -1830,6 +1831,7 @@
                                        returnstatus = -1;
                                if (option_verbose > 2)
                                        ast_verbose(VERBOSE_PREFIX_3 "AGI Script %s completed, returning %d\n", request, returnstatus);
+                               waitpid(pid, status, 0);
                                /* No need to kill the pid anymore, since they closed us */
                                pid = -1;
                                break;
@@ -1976,13 +1978,15 @@
 #endif
        res = launch_script(argv[0], argv, fds, enhanced ? &efd : NULL, &pid);
        if (res == AGI_RESULT_SUCCESS) {
+               int status = 0;
                agi.fd = fds[1];
                agi.ctrl = fds[0];
                agi.audio = efd;
-               res = run_agi(chan, argv[0], &agi, pid, dead);
+               res = run_agi(chan, argv[0], &agi, pid, &status, dead);
                close(fds[1]);
                if (efd > -1)
                        close(efd);
+               ast_verbose("status: %d\n", status);
        }
        ast_localuser_remove(me, u);