Magnanimous Monks, myriad musings mottle my moody mind. Maybe many mighty mentors might minister me memorable motions mending my malady? (I've been waiting to post that for months - alliteration is dorky but *fun!*) :)

OK, here's what I came for:

I have a program that forks off a pile of long-running children. Actually, the child processes should probably *never* return or die, in normal operation.

The code I've already written (simplified version below in the readmore section) simply reports info about dead children to a log, but now I need to do more...

The calls to fork are done inside a loop that looks like this:
my %child_info; foreach my $params (@params_for_children) { if ( my $pid = fork() ) { $child_info{$pid} = $params; } else { do_childish_things($params); croak "Child fork exited - should never happen\n"; } } while ( my $pid = wait() ) { last if $pid = -1; my $exit_status = $?; report_dead_child($pid, $exit_status, $child_info{$pid}); }

Generally, this works very well, but there are some things I need to add and I'm somewhat uncertain about how I would best go about it.


SO... I need advice with the following requirements:

My main question is this:

Is the code above a bad way for me to do this?
and,
Should I continue writing my own solution(s) or is there a robust CPAN module that will do this for me with less hassle?


In reply to Keeping children alive persistiently, intelligently by Hercynium

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.