Matt Sergeant asked: > I have an error on my server that I think is caused by an infinite loop in > perl code [*]. Does anyone have a reliable way to detect where this is > happening on a server with lots of code? > ---- $SIG{ALRM} = sub { Carp::confess("Got Apache::Event ALRM"); }; alarm(300); ---- Replacing 300 with some amount which any process should finish in.
Not elegent, but it seems to work. For instance, this: ---- use Carp; $SIG{ALRM} = sub { Carp::confess("Got Apache::Event ALRM"); }; alarm(3); temp(); sub temp { sleep(5); } ---- ...gives this result: ---- Got Apache::Event ALRM at testal.pl line 4 main::__ANON__('ALRM') called at testal.pl line 9 main::temp() called at testal.pl line 7 ---- ...which even shows which line Perl was up to when the SIGALRM was called (line 9 in this case).