Hi,

The last patch was broken (untested...), fixed, sorry.


Lace
--- Asterisk/AGI.pm-orig        2003-08-07 20:04:01.000000000 +0200
+++ Asterisk/AGI.pm     2004-11-22 19:49:41.402891515 +0100
@@ -190,6 +190,40 @@
        return $ret;
 }
 
+=item $AGI->hangup_aware()
+
+Prevent automatic termination of the AGI script on the line hangup.
+You should call this function if you need to take care of special cleanup
+functions _after_ the line has been hungup.
+
+You must carefully check all the returns codes to terminate properly on
+returned -1 (line hangup) values, otherwise a lot of stale processes remain on
+your system running.
+
+WARNING: Modifies Perl $SIG{"HUP"} and $SIG{"PIPE"} handlers!
+
+Example:
+    $AGI->hangup_aware();
+    if (-1==$AGI->stream_file("playme")) {
+        print LOGFILE "Finished after ".(time()-$timestamp_start)." seconds\n";
+       exit 0;
+    }
+
+Returns: 0 as the success.
+
+=cut
+
+sub hangup_aware {
+       my ($self) = @_;
+
+       # We will really get SIGHUP on the line hangup.
+       for (qw(HUP PIPE)) {
+               $SIG{$_}=eval 'sub { warn "Line hangup - got SIG'.$_.'\n"; };';
+       }
+
+       return 0;
+}
+
 =item $AGI->send_text($text)
 
 Executes AGI Command "SEND TEXT "$text"

Reply via email to