in reply to Re: Sequential processing with fork.
in thread Sequential processing with fork.
Stevieb,
Thank you! Your code seemed to point me in the right direction and do just what I needed, (after trying several other examples) the only problem is for what ever reason it doesn't progress to the next process after the initial group is started.
As I mentioned earlier I'm actually calling on another file and passing it the client ID via @ARGV, so it's not like it's simply a lexical scope that's being forked.
I've tried using exec, system to no avail. After one of the original group processes ends, it doesn't start another one to replace it or create a new one to run the next client.
After all the initial processes finish the main program just ends. :-( Any idea what could be going on?
Here's what I'm working with..
#!/usr/bin/perl use warnings; use strict; use Uber qw / client_list /; use Parallel::ForkManager; my $max_forks = 2; # Changed to 2 just to see if it would go to the ne +xt one... my $clients = client_list(); my $fork = new Parallel::ForkManager($max_forks); for my $client ( @$clients ){ $fork->start( $client->{id} ) and next; do_something( $client->{id} ); $fork->finish; } sub do_something { my $client = shift; system( "perl", "C:/Path/To/Folder/process.pl", "$client" ); } $fork->wait_all_children
|
|---|