in reply to How debug

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());

Replies are listed 'Best First'.
Re^2: How debug
by xiaoyafeng (Deacon) on Mar 20, 2007 at 03:09 UTC
    Thanks for your answer!

    Changing system func to print would be a good idea.Let me try.But no offense to you,I don't think I need to add $count -- statement.What I mean in this snippet is waiting until a child process complete.

    PS.your XP chart is very interesting! how do it? :)

    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction