[Asterisk-Users] AGI script always returning 0

Benoît Mérouze benoit.merouze at ipercom.com
Mon Nov 28 08:22:13 MST 2005


Hello,

I've noticed my AGI, in Perl, was always returning 0 even if exit from 
it with something else than 0.
On http://www.voip-info.org/wiki/view/Asterisk+cmd+AGI, it's said : 
"[AGI] Returns -1 on hangup or if application requested hangup, or 0 on 
non-hangup exit." But I tried also to hang up during the execution of 
the AGI and it's the same.

I also tried to use setcallback like that:
-----------------------------------------------------------------------------
# send callback reference
$AGI->setcallback(\&callback);

# our callback function
sub callback(){
    my ($returncode) = @_;
    warn "The call has ended ($returncode)\n";

    exit($returncode);
}
-----------------------------------------------------------------------------
The $returncode is set to -1 when I hung up my phone, but in Asterisk 
logs there is still "AGI Script pps.agi completed, returning 0".

Is that the normal behavior of Asterisk? Or is it possible to get -1 or 
any other code when finishing the execution of an AGI?

Thanks,
Benoit

-- 
Benoit Merouze
Network Software Developer
benoit.merouze at ipercom.com




More information about the asterisk-users mailing list