Perhaps I'm not fully understanding the question, but it seems like the solution you have, and the ones already given by pizza_milkshake, are overcomplicating things a bit. Here's how I'd code this thing:
use strict; use warnings; my @isolist = qw(one two three four five); # should contain ISO names while (my @workunit = splice @isolist, 0, 3) { my @pids; for (0 .. $#workunit) { push @pids, burncd($workunit[$_], $_); } waitpid $_, 0 for @pids; print "Work unit finished.\n"; if (@isolist) { # perhaps a prompt here to put in new blanks print "Starting next round...\n"; sleep 3; } } sub burncd { my ($isoname, $target) = @_; my $pid = fork; die "Cannot fork: $!" unless defined $pid; return $pid if $pid; print "Burning $isoname to cdrw$target\n"; # burn the cd. randomized sleep just for testing. sleep int rand(5) + 5; exit; }
In reply to Re: forking and ipc
by revdiablo
in thread forking and ipc
by hambo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |