in reply to Why I got so many CLOSE_WAIT
Are you reaping your child processes?
If you don't want to deal with child processes at all when they terminate (i.e., just let them finish and that's that and let them disappear from the process table as soon as they're done), you can set $SIG{CHLD} to 'IGNORE' (if I'm remembering correctly). If you need to do something more elaborate, then that signal entry should be set to a coderef, as usual.
As far as pasting code into Perlmonks, you should wrap it in <code> tags and, if it's lengthy, also in <readmore> tags, like this...
<readmore><code>Here is some example code below...
</code></readmore>#!/usr/bin/perl # Your code here.
update: Here's his handler, from the code at the other end of the URI he provided:
$SIG{CHLD}=sub {while((my $child=waitpid(-1,WNOHANG))>0){delete $CHILDREN{$child};$CHILD_COUNT--}};I don't see what's wrong with that (apart from the minor redundancy of keeping a $CHILD_COUNT when it looks like calling keys %CHILDREN in scalar context would probably provide the same information), but I haven't done a lot in the past with reaping child processes, so there could be something I'm overlooking.
|
|---|