Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
brutally stop a perl program if it runs too longby water (Deacon) |
on Sep 13, 2005 at 01:36 UTC ( [id://491431]=perlquestion: print w/replies, xml ) | Need Help?? |
water has asked for the wisdom of the Perl Monks concerning the following question:
I have some perl code that needs to be stopped if it runs for more than N seconds. The stop can be brutal; no need to clean up.
The alarm docs warn against mixing alarm and sleep in the same program. I also want to place the stop-me-if-run-for-more-than-N-secs in a module; the module doesn't know anything about the code that will use it. Given that, what's the best way to zap a process if it runs too long? Need I spawn another process to kill the parent after a time limit? Is there a system linux flag that accomplish this on the command line? Or is SIGALARM my best bet? Thanks
Back to
Seekers of Perl Wisdom
|
|