[olug] Alarms in Perl.
Dave Weis
djweis at internetsolver.com
Fri Oct 26 14:19:20 UTC 2007
On Thu, 25 Oct 2007, Daniel Linder wrote:
> Questions:
> 1: Will (should) this work even if the "long_running_code()" uses system()
> and or back-ticks to call out to external programs? (I realize those
> programs could be left running - I'm ok with having the admin clean them
> up once they are alerted to the code not returning at all...)
Yes it should work fine. Generally the children will also get killed
unless they are in uninterruptible sleep (reading from disk, etc).
> 2: Are the alarm() and Object::Destroyer calls part of the base Perl
> modules, or will I be visiting CPAN to get this working? (How do I check
> what's included out of the box vs. what has been installed over time?)
alarm should be there already, if Object isn't it wouldn't be hard to ad.
> 3: Is there any command-line magic that perl can be invoked with that will
> cause Perl to call a specific function if it is left running for a long
> period of time? (i.e. perl --timeout 300 --timeout-sub
> 'MyExitSubroutine()' ./MyBigPerlScript.pl)
You could do something similar with a shell script but inside the perl
script is probably cleaner.
dave
--
Dave Weis
djweis at internetsolver.com
http://www.internetsolver.com/
More information about the OLUG
mailing list