hi smart guys, i've written a simple perl server running under sunos5.8 as part of a bigger project. this server is set up to fork a child for each request. the server has to interact with a mysql db, so i used the standard dbi module to query my data source. i've modified a bit the standard reaping code i found in the perlipc manpage to suit my needs but it seems that some SIGCHLDs are just ignored, letting orphans children wandering about... soon, i realized the process table fills up with defunct processes over a relatively short running time, causing hell of trouble! i'm almost sure the problem resides in the reaping code. the number of requests per sec is very high, so i suppose some SIGCHLD handlings overlap. any ideas? thanks in advance...
my $waitedpid = 0; my %dbh_pool = (); sub REAPER { $waitedpid = waitpid(-1,WNOHANG); $SIG{CHLD} = \&REAPER; if (defined $waitedpid && $dbh_pool{$waitedpid}{"Active"}) { $dbh_pool{$waitedpid}->disconnect; delete $dbh_pool{$waitedpid}; } } $SIG{CHLD} = \&REAPER;

In reply to reaping defunct children by Anonymous Monk

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.