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?