mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-25 07:01:09 +00:00
Detect another way for a connection to have gone away.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@116296 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -249,6 +249,7 @@ static int app_exec(struct ast_channel *chan, void *data)
|
|||||||
int child_stdout[2] = { 0,0 };
|
int child_stdout[2] = { 0,0 };
|
||||||
int child_stderr[2] = { 0,0 };
|
int child_stderr[2] = { 0,0 };
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
int test_available_fd = -1;
|
||||||
int gen_active = 0;
|
int gen_active = 0;
|
||||||
int pid;
|
int pid;
|
||||||
char *argv[32];
|
char *argv[32];
|
||||||
@@ -367,6 +368,8 @@ static int app_exec(struct ast_channel *chan, void *data)
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_available_fd = open("/dev/null", O_RDONLY);
|
||||||
|
|
||||||
setvbuf(child_events, NULL, _IONBF, 0);
|
setvbuf(child_events, NULL, _IONBF, 0);
|
||||||
setvbuf(child_commands, NULL, _IONBF, 0);
|
setvbuf(child_commands, NULL, _IONBF, 0);
|
||||||
setvbuf(child_errors, 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) {
|
} else if (ready_fd == child_errors_fd) {
|
||||||
char input[1024];
|
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");
|
ast_chan_log(LOG_WARNING, chan, "Child process went away\n");
|
||||||
res = -1;
|
res = -1;
|
||||||
break;
|
break;
|
||||||
@@ -533,6 +536,10 @@ static int app_exec(struct ast_channel *chan, void *data)
|
|||||||
if (child_errors)
|
if (child_errors)
|
||||||
fclose(child_errors);
|
fclose(child_errors);
|
||||||
|
|
||||||
|
if (test_available_fd > -1) {
|
||||||
|
close(test_available_fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (child_stdin[0])
|
if (child_stdin[0])
|
||||||
close(child_stdin[0]);
|
close(child_stdin[0]);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user