On Thu, 7 Jan 2010, JR Richardson wrote: > I'm running an AGI, calling a perl script the does number lookups to a > remote server. I would like to put a timeout in the script. The > problem I'm running into is if the DNS server is not responding, the > script hangs and waits for 30 seconds before returning to the Asterisk > dialplan. I would like a timeout of 1 second, then return.
I'm a C weenie, so I can't provide Perl code. But it should look something like this: // handle the alarm static void lookup_failed ( void ) { exit(EXIT_FAILURE); } int main ( ) ... // set a signal alarm handler signal(SIGALRM, (void (*)(int))(int)lookup_failed); // set the alarm to go off in 1 second alarm(1); // lookup my number do_lookup(dnis); // cancel the alarm alarm(0); ... Of course, solving the real issue (DNS lookups), or masking it with a local caching server or even a /etc/hosts file are viable alternatives. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 _______________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users