For testing code that forks, you might try replacing dbv_check with something that doesn't do a whole lot like:

sub fork_test { my ($file,$logfile)= @_; print "I'm working on file '$file', logfile '$logfile'.\n"; sleep 3; print "I'm done working.\n"; }

Then call m_fork with a relatively short file list (say 10 or 15 elements).

If it forks too much, you'll see lots of "I'm working" before seeing any "I'm done working." If it's working as you think it should, you should get five "I'm working" and a pause before anything else.

The code in m_fork increases $count but never decreases it. You might want to do something like:

while ( $count > $max ) { wait; $count--; }

One other suggestion: if you can't fork, it would be good for the error message to say why.

die "Can't fork: $!\n" unless defined(my $pid = fork());

In reply to Re: How debug by kyle
in thread How debug by xiaoyafeng

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.