Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: controlling child processes

by ikegami (Patriarch)
on Apr 04, 2006 at 22:10 UTC ( [id://541234]=note: print w/replies, xml ) Need Help??


in reply to controlling child processes

Three - is there a better way to go about doing this?

Yes. You are duplicating the functonality of Parallel::ForkManager. All you need is the following:

use strict; use warnings; use Parallel::ForkManager (); use constant $MAX_PROCESSES => 3; { my $pm = Parallel::ForkManager->new($MAX_PROCESSES); foreach my $fw (qw(fw1 fw2 fw3 fw4 fw5)) { my $pid = $pm->start and next; exec "remotelogfile $fw logfile > /var/$fw.log" or die("Unable to launch \"remotelogfile $fw\": $!\n"); # Will never reach this, but that's ok since it only calls exit. $pm->finish; # Terminates the child process } }
or just
use Parallel::ForkManager (); my $pm = Parallel::ForkManager->new(3); foreach my $fw (qw(fw1 fw2 fw3 fw4 fw5)) { $pm->start and next; exec "remotelogfile $fw logfile > /var/$fw.log"; die("Unable to launch \"remotelogfile $fw\": $!\n"); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://541234]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (9)
As of 2024-03-28 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found