Hello, ParallelForkManager seems to be causing me some serious headaches. Consider the following example: The following block is supposed to be run when the child process finishes.
$pm->run_on_finish( sub { my ($pid, $exit_code, $ident) = @_; print "** $ident just got out of the pool ". "with PID $pid and exit code: $exit_code\n"; } );
But it never does. Only when wait_all_children is included does the on_finish get run. We start a processor thread, because other threads are running as well (need not mention them here).
$thr4 = threads->new(\&processor); $thr4->detach; while (1){ sleep(1); #$pm->wait_all_children; }
sub processor{ my @row; while (1){ if ($sys_ok){ @row = &row_sql("select * from pool_process where srv='$se +rver_id';"); if (!(@row)){ #print "Nothing to do...\n"; }else{ &del_sql("delete from pool_process where id='@row[0]'; +"); print "Processing (@row[1],@row[2],@row[3],@row[4])\n" +; #my $thr = threads->create(\&process_start,@row[1],@ro +w[2],@row[3],@row[4],@row[5]); $child_processor++; my $pid = $pm->start($child_processor) and next; &process_start(@row[1],@row[2],@row[3],@row[4],@row[5]); print "Child about to get out ($$)\n"; system("kill $$"); $pm->finish($child_processor); # Terminates the chil +d process print "Finished Child!"; } sleep(2); }else{ sleep(30); } #$pm->wait_all_children; } }
Because $pm->wait_all_children is blocking, this prevents items to be processed from being added from an SQL Table, hence the while loop to look for new items. Without the blocking wait_all_children, things function as they should. However the system is left with TONS of zombie processes because finish never gets called. My only guess is it is because of the  while (1){sleep 1;} But that is required to leave the detached threads still running. The  system("kill $$"); is an attempt by me to get the zombie process ending. No dice. Even kill -9 (a supposed work around) does nothing. Any and all help is really appreciated.

In reply to Parallel Fork Manager -- Can't kill zombies! by expresspotato

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.