diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-08-03 04:17:12 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-08-03 04:17:12 +0000 |
commit | b0a41e75a0cc9f74dacb53dd14a411526d906ff7 (patch) | |
tree | 3f0d3437f8264f2db99d7041d5e2ba9047a3ef5b /res | |
parent | 0a8db4e778717bda40884446c01299389a6fc946 (diff) |
Fix sighup with AGI (bug #4854)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6264 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-x | res/res_agi.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index f31591e3e..a6bb7c98b 100755 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -211,6 +211,7 @@ static int launch_script(char *script, char *argv[], int *fds, int *efd, int *op int audio[2]; int x; int res; + sigset_t signal_set; if (!strncasecmp(script, "agi://", 6)) return launch_netscript(script, argv, fds, efd, opid); @@ -266,9 +267,17 @@ static int launch_script(char *script, char *argv[], int *fds, int *efd, int *op } else { close(STDERR_FILENO + 1); } + + /* unblock important signal handlers */ + if (sigfillset(&signal_set) || pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) { + ast_log(LOG_WARNING, "unable to unblock signals for AGI script: %s\n", strerror(errno)); + exit(1); + } + /* Close everything but stdin/out/error */ for (x=STDERR_FILENO + 2;x<1024;x++) close(x); + /* Execute script */ execv(script, argv); /* Can't use ast_log since FD's are closed */ @@ -430,7 +439,7 @@ static int handle_tddmode(struct ast_channel *chan, AGI *agi, int argc, char *ar if (!strncasecmp(argv[2],"tdd",3)) x = 1; res = ast_channel_setoption(chan, AST_OPTION_TDD, &x, sizeof(char), 0); - if(res != RESULT_SUCCESS) + if (res != RESULT_SUCCESS) fdprintf(agi->fd, "200 result=0\n"); else fdprintf(agi->fd, "200 result=1\n"); @@ -467,7 +476,7 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char return RESULT_SHOWUSAGE; fs = ast_openstream(chan, argv[2], chan->language); - if(!fs){ + if (!fs){ fdprintf(agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset); return RESULT_SUCCESS; } @@ -523,7 +532,7 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char * } fs = ast_openstream(chan, argv[2], chan->language); - if(!fs){ + if (!fs){ fdprintf(agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset); ast_log(LOG_WARNING, "Unable to open %s\n", argv[2]); return RESULT_SUCCESS; @@ -1817,8 +1826,10 @@ static int run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid, i } } /* Notify process */ - if (pid > -1) - kill(pid, SIGHUP); + if (pid > -1) { + if (kill(pid, SIGHUP)) + ast_log(LOG_WARNING, "unable to send SIGHUP to AGI process %d: %s\n", pid, strerror(errno)); + } fclose(readf); return returnstatus; } |