Limit running time to a program

There is no obvious way to specify that a program should run for no longer than x seconds. The following stackoverflow question solves it in a very perlish-way. Define a helper function doalarm:

<code>$ doalarm () { perl -e 'alarm shift; exec @ARGV' "$@"; } # define a helper function
</code>

And you are done.

<code>$ doalarm 300 ./my_prog
</code>

will run for at most 300 seconds.