aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_externalivr.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/app_externalivr.c')
-rw-r--r--apps/app_externalivr.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index eb1989c62..7c9be392c 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -432,6 +432,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
struct ast_channel *rchan;
char *command;
int res = -1;
+ int test_available_fd = -1;
FILE *eivr_commands = NULL;
FILE *eivr_errors = NULL;
@@ -451,6 +452,8 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
goto exit;
}
}
+
+ test_available_fd = open("/dev/null", O_RDONLY);
setvbuf(eivr_events, NULL, _IONBF, 0);
setvbuf(eivr_commands, NULL, _IONBF, 0);
@@ -522,7 +525,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
} else if (ready_fd == eivr_commands_fd) {
char input[1024];
- if (exception || feof(eivr_commands)) {
+ if (exception || (dup2(eivr_commands_fd, test_available_fd) == -1) || feof(eivr_commands)) {
ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
res = -1;
break;
@@ -633,7 +636,11 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
exit:
- if (eivr_events)
+ if (test_available_fd > -1) {
+ close(test_available_fd);
+ }
+
+ if (eivr_events)
fclose(eivr_events);
if (eivr_commands)