On Thursday 22 June 2006 10:42, Matthew Gregg wrote:
> I'm using the module successfully except for callbacks.  I need to
> setup a callback to catch hangups and run some cleanup routines. 
> I've read the docs and some example code, none of which I can get
> to work(the callback seems to never be called).
>
> $AGI = new Asterisk::AGI;
> $AGI->setcallback(\&hangup_callback);
> my %input = $AGI->ReadParse();
>
> ....some code here.....
>
>
> sub hangup_callback {
>         my ($returncode) = @_;
>         unlink "$uniqid.wav";
>         print STDERR "MYCALLBACK: User Hungup ($returncode)\n";
>         exit($returncode);
> }
>
>
>
> Any idea what I'm doing wrong?

Yep, you've never intercepted SIGHUP, so the signal is killing your
process before it has time to receive anything back from the AGI
socket.  Try:

$SIG{HUP} = 'IGNORE';

or (better):

$SIG{HUP} = \&handle_hangup;

-- 
Tilghman

Reply via email to