use strict; use warnings; if (my $pid = fork) { eval { local $SIG{ALRM} = sub{die "Timeout hit\n"}; alarm 1; wait; alarm 0; 1; } or do { print $@; kill 9, $pid; } } else { magick_die(); exit; } sub magick_die { my $var = 0; for (1 ... 1000000) { $var++ for 1 .. 1000000; } }
If you need to pass information back and forth, you could serialize over pipes.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
In reply to Re^3: die through several evals
by kennethk
in thread die through several evals
by nyaapa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |