[asterisk-users] AGI script exits non-zero when running system command

Tilghman Lesher tilghman at meg.abyt.es
Wed Feb 2 13:13:56 CST 2011


On Tuesday 01 February 2011 23:43:34 Charles Solar wrote:
> Hey guys I was hoping I could get a few pointers on a problem I have
> been trying to debug for the last couple of months regarding asterisk
> AGI scripts and unexpected termination.
> I have this agi script that accepts incoming faxes using RxFax on the
> latest asterisk 1.4 branch. Its written with perl and it works fine
> except for one line that causes the entire script to terminate
> unexpectedly.
<snip>
> AGI Tx >> 200 result=0
> AGI Rx << VERBOSE "Converting /tmp/1296624119.53.tiff to
> /tmp/1296624119.53.pdf" 1
>   fax.agi: Converting /tmp/1296624119.53.tiff to /tmp/1296624119.53.pdf
> AGI Tx >> 200 result=1
> Really destroying SIP dialog '371b80c6324ece0c779653c34d2e88a2 at XXX'
> Method: INVITE
>   == Spawn extension (from-trunk, XXXXXXXXXX, 3) exited non-zero on
> 'SIP/trunk-00000035'

This isn't the script terminating non-zero.  It's the channel hanging up.

One possible problem might be that your script is not properly handling the
SIGHUP signal sent to the AGI process when a hangup occurs.  If that is the
case, then your script may be terminating early due to the signal.  The
best way to handle that is to set a signal handler in your script (this is
dependent upon the language you're using), although there's also a
workaround for people who are unwilling or unable to set a signal handler.

Just remember that prior to Asterisk 1.6.2, once you receive the SIGHUP,
you may no longer interact with the Asterisk process.  That includes
setting and retrieving variables and using the VERBOSE command.  Starting
with Asterisk 1.6.2, an AGI is free to continue interacting with Asterisk
(the setting of final variables is likely the most productive task).

-- 
Tilghman



More information about the asterisk-users mailing list