aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_agi.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-17 12:56:38 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-17 12:56:38 +0000
commitf2329d26d213f4d635d79aa51befa1938a48462e (patch)
tree691987291ab7cb5bbe3dcda928d5aa16727124ed /res/res_agi.c
parent664f4f1f8bfa9fcc422ef107f344d8400d6d2099 (diff)
Add special case for when the agi cannot be executed, to comply with the documentation that
we return failure in that case. (closes issue #12462) Reported by: fmueller Patches: 20080416__bug12462.diff.txt uploaded by Corydon76 (license 14) Tested by: fmueller git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@114195 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_agi.c')
-rw-r--r--res/res_agi.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index b0de6db36..4b23b0110 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -346,6 +346,8 @@ static enum agi_result launch_script(char *script, char *argv[], int *fds, int *
execv(script, argv);
/* Can't use ast_log since FD's are closed */
fprintf(stdout, "verbose \"Failed to execute '%s': %s\" 2\n", script, strerror(errno));
+ /* Special case to set status of AGI to failure */
+ fprintf(stdout, "failure\n");
fflush(stdout);
_exit(1);
}
@@ -1904,6 +1906,12 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
break;
}
+ /* Special case for inability to execute child process */
+ if (*buf && strncasecmp(buf, "failure", 7) == 0) {
+ returnstatus = AGI_RESULT_FAILURE;
+ break;
+ }
+
/* get rid of trailing newline, if any */
if (*buf && buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
@@ -2047,6 +2055,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
}
}
#endif
+ ast_replace_sigchld();
res = launch_script(argv[0], argv, fds, enhanced ? &efd : NULL, &pid);
if (res == AGI_RESULT_SUCCESS || res == AGI_RESULT_SUCCESS_FAST) {
int status = 0;
@@ -2062,8 +2071,8 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
close(fds[1]);
if (efd > -1)
close(efd);
- ast_unreplace_sigchld();
}
+ ast_unreplace_sigchld();
ast_module_user_remove(u);
switch (res) {