Hey, i've just joined perl monks and I don't know if this is the right area to place my question but here it goes: I've been trying to play with Parallel::ForkManager to fork a program i wrote, I've been playing around with sample forkmanager code as follows:
use strict; use Parallel::ForkManager; print "Content-Type: text/html\n\n"; my $max_procs = 5; my @names = qw( Fred Jim Lily Steve ); # hash to resolve PID's back to child specific information my $pm = new Parallel::ForkManager($max_procs); # Setup a callback for when a child finishes up so we can # get it's exit code $pm->on_finish( sub { my ($pid, $exit_code, $ident) = @_; print "** $ident just got out of the pool <br>". "with PID $pid and exit code: $exit_code<br>\n"; } ); $pm->on_start( sub { my ($pid,$ident)=@_; print "** $ident started, pid: $pid<br>\n"; } ); $pm->on_wait( sub { print "** Have to wait for one children ...<br>\n" } ); foreach my $child (0 .. $#names ) { my $pid = $pm->start($names[$child]) and next; # This code is the child process print "This is $names[$child], Child number $child<br>\n"; # sleep ( 2 * $child ); print "$names[$child], Child $child is about to get out...<br>\n"; sleep 1; # pass an exit code to finish $pm->finish($child); } print "Waiting for Children...<br>\n"; $pm->wait_all_childs; print "Everybody is out of the pool!<br>\n";
When i try out this program it seems like none of the children are exiting at all...Any ideas on why it would be doing so? I'm quite confused and finally found Parallel::ForkManger, does anyone have comments on it or have better modules to use when playing with fork()? I appreciate your time fellow monks.

In reply to Fork() confusion by dkode

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.