Hi all,
I'm using fork() and waitpid(0 and am having trouble reaping my dead children when processing a CGI. I can run similar code from the command line and it works fine... but for some reason, when the CGI is processing... the first child is reaped... but all subsequent children just run forever... here's the code snippet:
 
The @arrServerChecks array simply contains a list of UNC paths...

my @kids;
while (1) {
  if (my $strPath = shift (@arrServerChecks)) {
    my $pid = fork();
    push @kids, $pid;
    die "Can't fork: $!" unless (defined ($pid));
     
    if (!$pid) {
      if (-e $strPath) {
        print "Good: ".$pid." - ".$strPath."\n";
        print NAMEFILE $strPath."\n";
      }
      exit;
    }
    print "Child $pid Started<br>";
  } else {
    last;
  }
 
  my @newkids;
  foreach my $child (@kids) {
    print $child."<br>";
    if (waitpid ($child, WNOHANG) == $child) {
      print "Child $child Died - ".$?."<br>";
    } else {
      push @newkids, $child;
    }
  }
  print "I have ".(scalar (@kids))." kids... ".$child."<br>";
  @kids = @newkids;
  sleep 1;
}
 
The output I get from the web server (IIS 6.0) is:
 
Good: 0 - \\XLBEARA01M\d$\apps\oracle\network\ADMIN\tnsnames.ora Child -10180 Started
-10180
I have 1 kids...
Child -5076 Started
-10180
Child -10180 Died - 0
-5076
I have 2 kids...
Child -11468 Started
-5076
-11468
I have 2 kids...
Child -6024 Started
-5076
-11468
-6024
I have 3 kids...
Child -11192 Started
-5076
-11468
-6024
-11192
I have 4 kids...
Good: 0 - \\XLBEARF01M\d$\apps\oracle\network\ADMIN\tnsnames.ora Child -4788 Started
-5076
-11468
-6024
-11192
-4788
I have 5 kids...
 
 
and it goes on and on from there... until I max out at 64 threads... as you can see... the first child (PID -10180) is reaped... but the rest never seem to die... can anyone clue me into why that is?... I'm running ActiveState Perl 5.6.0 Build 623...
 
Thanks,
 
Andy Speagle
_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to