[asterisk-users] How to avoid AGI script is canceled if callerHangUp

Tilghman Lesher tlesher at digium.com
Wed Feb 10 17:51:51 CST 2010


On Wednesday 10 February 2010 17:13:09 Steve Edwards wrote:
> Un-top-posting...
>
> > [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Thomas
> > Winter
> >
> > is there any way to avoid cancel the AGI script if caller is hanging up.
> > That gives me sometimes data mismatch and it is deffcault to clean up in
> > the h extension.
> >
> > I would like that the PHP script called by AGI will run to end..
>
> On Wed, 10 Feb 2010, Danny Nicholas wrote:
> > According to the CLI doc, you can do it this way
> > - exten => 100,1,Set(AGISIGHUP=no)
> > - exten => 100,n,AGI(youragi.agi)
>
> Who knew? Hey TP, I learned something new today!
>
> Another approach, is to establish a signal handler -- so you can handle
> the signal :)
>
> I write my AGIs in C (because you can execute xxx AGIs written in C in the
> time it takes to load PHP and parse your script) so it looks like this:
>
> // trap SIGHUP -- caller hung up
>          signal(SIGHUP, (void (*)(int))(int)hangup);
>
> When the caller hangs up, Asterisk delivers a SIGHUP to the process
> created by the agi() application. Execution of your AGI will then continue
> with your signal handler where you can clean up temporary files, roll back
> database cruft, etc.

One thing that you cannot do in 1.4 is continue to interact with the AGI
interface, however.  You can handle the signal, but once it is sent, you can
no longer interact with Asterisk.  This deficiency is fixed in the 1.6 series.

-- 
Tilghman Lesher
Digium, Inc. | Senior Software Developer
twitter: Corydon76 | IRC: Corydon76-dig (Freenode)
Check us out at: www.digium.com & www.asterisk.org



More information about the asterisk-users mailing list