aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_externalivr.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-14 16:46:48 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-14 16:46:48 +0000
commit6abc2f08f5374aa83dc0a8c0a09850d9a16cdb7a (patch)
tree84f642a2ecd0c114839d7dc504abe482bfa4bf54 /apps/app_externalivr.c
parent04213ea2a92ab0033fc177d55aa9e0842f24244b (diff)
Detect another way for a connection to have gone away.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@116296 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_externalivr.c')
-rw-r--r--apps/app_externalivr.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index de905997e..8004fecd1 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -249,6 +249,7 @@ static int app_exec(struct ast_channel *chan, void *data)
int child_stdout[2] = { 0,0 };
int child_stderr[2] = { 0,0 };
int res = -1;
+ int test_available_fd = -1;
int gen_active = 0;
int pid;
char *argv[32];
@@ -367,6 +368,8 @@ static int app_exec(struct ast_channel *chan, void *data)
goto exit;
}
+ test_available_fd = open("/dev/null", O_RDONLY);
+
setvbuf(child_events, NULL, _IONBF, 0);
setvbuf(child_commands, NULL, _IONBF, 0);
setvbuf(child_errors, NULL, _IONBF, 0);
@@ -500,7 +503,7 @@ static int app_exec(struct ast_channel *chan, void *data)
} else if (ready_fd == child_errors_fd) {
char input[1024];
- if (exception || feof(child_errors)) {
+ if (exception || (dup2(child_commands_fd, test_available_fd) == -1) || feof(child_errors)) {
ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
res = -1;
break;
@@ -533,6 +536,10 @@ static int app_exec(struct ast_channel *chan, void *data)
if (child_errors)
fclose(child_errors);
+ if (test_available_fd > -1) {
+ close(test_available_fd);
+ }
+
if (child_stdin[0])
close(child_stdin[0]);