use warnings; use strict; my $fuse = 10; # Seconds foreach (<*.mp3>) { print "$_\n"; # Update on progress # If the fork() produces a process... if (my $pid = fork()) { # ...wait for it to finish. wait(); } else { # This causes the process to exit on # an alarm call. $SIG{ALRM} = sub { exit(); }; # This sets the timer on the alarm alarm($fuse); # This runs a command that takes a long # time and has to be stopped early. system("/bin/sleep 10000"); # Important to exit() here or you'll # keep going through the loop creating # more processes! exit(); } }
In reply to Re: Timing External Program Execution
by tadman
in thread Timing External Program Execution
by cameronbprince
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |