Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I have a web script that I would like to prevent from running infinitely - due to unknown bugs for example. Is there a way to make it run for, say 5 mins, and then kill the process whether it's hung or has entered an infinite loop?
I tried the code below but it didn't work:
use Proc::Watchdog; my $w = Proc::Watchdog->new( { -path => '/tmp' } ); # stop process in 5 mins regardless of outcome $w->alarm(5); sub do_while { print "hi\n" while 1; } do_while(); $w->reset;
The watchlog file is created but the "do_while sub" continues to run after 5 secs. Am I missing something here?
Thank you for reading and I look forward to your kind replies.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Kill process after X mins
by Corion (Patriarch) on Jul 21, 2011 at 13:05 UTC | |
by pradeepprakhar (Initiate) on Apr 20, 2017 at 15:31 UTC | |
by Corion (Patriarch) on Apr 20, 2017 at 15:34 UTC | |
by pradeepprakhar (Initiate) on Apr 20, 2017 at 16:14 UTC | |
by Corion (Patriarch) on Apr 20, 2017 at 16:31 UTC | |
by Anonymous Monk on Jul 21, 2011 at 13:15 UTC | |
by Corion (Patriarch) on Jul 21, 2011 at 13:21 UTC | |
|
Re: Kill process after X mins
by locked_user sundialsvc4 (Abbot) on Jul 21, 2011 at 14:54 UTC | |
by Anonymous Monk on Jul 22, 2011 at 14:19 UTC |