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

Thanks again, zentara.

Ugh. The whole reason I chose to use Capture::Tiny (after much research) is because it purports to solve all the problems that all the other methods of forking and exec-ing on Windows do not. I read its author's presentation titled How (Not) to Capture Output in Perl.

I certainly hope I don't have to abandon using Capture::Tiny now. After all, it's working brilliantly. What's failing is something related to my use of Parallel::ForkManager.

  • Comment on Re^4: Adding parallel processing to a working Perl script

Replies are listed 'Best First'.
Re^5: Adding parallel processing to a working Perl script
by zentara (Cardinal) on Apr 21, 2014 at 20:31 UTC
    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