On Mon, Apr 14, 2008 at 9:45 AM, anthony brooke <[EMAIL PROTECTED]> wrote: > > Thanks for the reply, but sometimes I don't know where is the code that cause > the infinite loop. > Is there such as thing as perl configuration file, to set the execution time > for any code, any where > in the program just like php.ini file. Thanks.
No, but you could just create a script like #!/usr/bin/perl use strict; use warnings; my $timeout = shift; my $rc; my $pid = fork; eval { $SIG{ALRM} = sub { die "timeout\n" }; die "could not fork" unless defined $pid; if ($pid) { alarm $timeout; waitpid $pid, 0; $rc = $? >> 8; } else { exec "/usr/bin/perl", @ARGV; } }; if ($@) { kill "SIGTERM", $pid; print "died with: [EMAIL PROTECTED]"; } else { print "exit code was: $rc\n"; } and then run it like this: timout.pl 60 script_that_should_die_in_60_seconds.pl -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/