Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: Adding parallel processing to a working Perl script

by zentara (Archbishop)
on Apr 21, 2014 at 20:31 UTC ( [id://1083082]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Adding parallel processing to a working Perl script
in thread Adding parallel processing to a working Perl script

What's failing is something related to my use of Parallel::ForkManager.

Would you be willing to try a manual fork method?

For instance:

#!/usr/bin/perl #by Zaxo of perlmonks my @apps = ( [qw(/path/to/foo args of foo)], [qw(/path/to/bar args of it here)] ); #to avoid Zombies $SIG{CHLD} = 'IGNORE'; for (@apps) { defined(my $cpid = fork) or die $!; $cpid or exec {$_->[0]} @$_ or die $!; } exit 0; # the parent #If the apps don't run as daemons, you may need to have #them ignore SIGHUP or else call &POSIX::setsid so that #the parent's exit doesn't trigger an early demise of the kids.
or maybe try the following, remembering to try system(1,$cmd) instead of exec( $cmd)
#!/usr/bin/perl my $child=fork(); # Spawn off a child if ($child>0) { #parent exec ($app1) || die "Could not exec $app1:$!"; exit(0); # Should never get here! } elsif ($child == 0 ) { # Child process exec ($app2) || die "Could not exec $app2:$!"; exit(0); # should never get here either } else { die "Could not fork! $!"; } # Evaluating $! will give you the reason you couldn't # spawn the exec'ed process.

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-19 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found