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 |