Summary: | ASTERISK-12908: AGI-program receives SIGHUP on hangup although AGISIGHUP is set to "no" | ||
Reporter: | Fabian Mueller (fmueller) | Labels: | |
Date Opened: | 2008-10-15 17:23:36 | Date Closed: | 2008-12-22 17:27:33.000-0600 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Resources/res_agi |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) 13711.patch | |
Description: | I added a LOG_WARNING message to res_agi.c: if (needhup) { needhup = 0; dead = 1; if (pid > -1) { ast_log(LOG_WARNING, "this is executed\n"); kill(pid, SIGHUP); } else if (agi->fast) { send(agi->ctrl, "HANGUP\n", 7, MSG_OOB); } } I have this AGI-program: #include <stdio.h> int main(int argc, char *argv[]) { int i; for (i=0; i<50; i++) { fprintf(stderr, "message %d\n", i); sleep(1); } return 0; } I call it and hangup while it is writing the messages to the CLI. This is written to the CLI: *CLI> == Using SIP RTP CoS mark 5 -- Executing [69@default:1] Answer("SIP/222-0822f9c0", "") in new stack -- Executing [69@default:2] Set("SIP/222-0822f9c0", "AGISIGHUP="no"") in new stack -- Executing [69@default:3] AGI("SIP/222-0822f9c0", "test") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/test message 0 message 1 [Oct 16 00:18:09] WARNING[7980]: res_agi.c:2639 run_agi: this is executed -- <SIP/222-0822f9c0>AGI Script test completed, returning -1 *CLI> Obviously the AGI-program receives SIGHUP when I hangup. But because AGISIGHUP is set to "no" the AGI-program should not reveice that signal according to the documentation (core show application agi). Tested version is Asterisk 1.6.0.1. | ||
Comments: | By: Tilghman Lesher (tilghman) 2008-10-15 21:55:32 You set AGISIGHUP to "\"no\"", not "no". Notice the extra quotes in there. What you should have done was: Set(AGISIGHUP=no) and then it will work. By: Fabian Mueller (fmueller) 2008-10-16 05:37:37 No, it does no work. It does not matter if I use Set(AGISIGHUP=no) or Set(AGISIGHUP="no"). The part from res_agi.c that I posted in my report is always executed. It is executed independently from the value of AGISIGHUP. The value of AGISIGHUP is only relevant at the end of the for-loop in run_agi(). By: Mark Michelson (mmichelson) 2008-10-16 16:55:45 Does 13711.patch make sense? It grabs the value of AGISIGHUP at the beginning of run_agi and uses what is read there to determine whether to send a SIGHUP at all places that Asterisk may currently send that signal. By: Fabian Mueller (fmueller) 2008-10-17 16:50:10 In asterisk-1.4.22 we have this at the beginning of run_agi() if (!(readf = fdopen(agi->ctrl, "r"))) { ast_log(LOG_WARNING, "Unable to fdopen file descriptor\n"); if (pid > -1) kill(pid, SIGHUP); close(agi->ctrl); return AGI_RESULT_FAILURE; } Therefore the kill function is executed independently from the value of AGISIGHUP. In your patch this behaviour is changed. Was this change done intentionally? Or should probably asterisk-1.4 be updated accordingly? By: Mark Michelson (mmichelson) 2008-12-18 14:02:07.000-0600 This change was done intentionally, the idea being that if AGISIGHUP is set, then we should never send the SIGHUP signal under any circumstance. Sorry for not getting back to you sooner on this. I must not have noticed that you had asked a question of me earlier :( By: Fabian Mueller (fmueller) 2008-12-20 17:34:32.000-0600 Ok, so from my point of view your patch can be applyed. By: Digium Subversion (svnbot) 2008-12-22 17:25:43.000-0600 Repository: asterisk Revision: 166470 U trunk/res/res_agi.c ------------------------------------------------------------------------ r166470 | mmichelson | 2008-12-22 17:25:43 -0600 (Mon, 22 Dec 2008) | 11 lines Always use the value of the AGISIGHUP when running an AGI. Prior to this patch, the value of AGISIGUP was not always honored when set on a channel. (closes issue ASTERISK-12908) Reported by: fmueller Patches: 13711.patch uploaded by putnopvut (license 60) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=166470 By: Digium Subversion (svnbot) 2008-12-22 17:26:58.000-0600 Repository: asterisk Revision: 166471 _U branches/1.6.0/ U branches/1.6.0/res/res_agi.c ------------------------------------------------------------------------ r166471 | mmichelson | 2008-12-22 17:26:58 -0600 (Mon, 22 Dec 2008) | 19 lines Merged revisions 166470 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r166470 | mmichelson | 2008-12-22 17:25:34 -0600 (Mon, 22 Dec 2008) | 11 lines Always use the value of the AGISIGHUP when running an AGI. Prior to this patch, the value of AGISIGUP was not always honored when set on a channel. (closes issue ASTERISK-12908) Reported by: fmueller Patches: 13711.patch uploaded by putnopvut (license 60) ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=166471 By: Digium Subversion (svnbot) 2008-12-22 17:27:32.000-0600 Repository: asterisk Revision: 166472 _U branches/1.6.1/ U branches/1.6.1/res/res_agi.c ------------------------------------------------------------------------ r166472 | mmichelson | 2008-12-22 17:27:32 -0600 (Mon, 22 Dec 2008) | 19 lines Merged revisions 166470 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r166470 | mmichelson | 2008-12-22 17:25:34 -0600 (Mon, 22 Dec 2008) | 11 lines Always use the value of the AGISIGHUP when running an AGI. Prior to this patch, the value of AGISIGUP was not always honored when set on a channel. (closes issue ASTERISK-12908) Reported by: fmueller Patches: 13711.patch uploaded by putnopvut (license 60) ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=166472 |