in reply to Re: Limiting script cpu time
in thread Limiting script cpu time
#!/usr/bin/perl -w $SIG{ALRM}= sub { my($user,$system) = (times)[0,1]; my $totaltime = $user + $system; if ($totaltime > 1.5) { if (fork() != 0) { # No error checking. Bad Monk! wait; exit(0); } } alarm(1); }; $| = 1; alarm(1); # Comment out to not use fork srand(0); for(my $i=0;$i<10_000_000;$i++) { if (($i % 1_000_000) == 0) { printf "%05d (pid %05d)\n", int(rand() * 10_000),$$; } }
If the limit is on that child and all of its children, you're pretty much screwed.
Apart from hack value, though, the real solution is to make your code more efficient, or else find a hosting provider that better meets your needs.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Limiting script cpu time
by sdbarker (Sexton) on Jun 11, 2003 at 14:07 UTC |