Hi Bill,
Thanks for the info... I tried your suggested code... though it doesn't look functionally much different from what I had... it returned the same result... with perhaps better output logging... I'll paste the output up through the 6th child thread.
--
Child: pid=0; NOPATH=\\XLBEARA01M\d$\apps\oracle\network\ADMIN\tnsnames.ora
Parent: Child -11404 Started
Parent: waitpid '-11404'
Parent: I have 1 kids
Parent: Child -6796 Started
Parent: waitpid '-11404'
Parent: Child -11404 Died (0)
Parent: waitpid '-6796'
Parent: I have 1 kids
Child: pid=0; NOPATH=\\XLBEARA01M\d$\apps\oraforms\NET80\ADMIN\tnsnames.ora
Parent: Child -3568 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: I have 2 kids
Parent: Child -11440 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: I have 3 kids
Child: pid=0; NOPATH=\\XLBEARA01M\e$\oracle\ora81\network\ADMIN\tnsnames.ora
Child: pid=0; NOPATH=\\XLBEARF01M\d$\apps\oracle\network\ADMIN\tnsnames.ora
Parent: Child -544 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: waitpid '-544'
Parent: I have 4 kids
Child: pid=0; NOPATH=\\XLBEARF01M\d$\apps\oraforms\NET80\ADMIN\tnsnames.ora
Parent: Child -10592 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: waitpid '-544'
Parent: waitpid '-10592'
Parent: I have 5 kids
Child: pid=0; NOPATH=\\XLBEARF01M\e$\oracle\ora81\network\ADMIN\tnsnames.ora
Parent: Child -10344 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: waitpid '-544'
Parent: waitpid '-10592'
Parent: waitpid '-10344'
Parent: I have 6 kids
Parent: Child -11404 Started
Parent: waitpid '-11404'
Parent: I have 1 kids
Parent: Child -6796 Started
Parent: waitpid '-11404'
Parent: Child -11404 Died (0)
Parent: waitpid '-6796'
Parent: I have 1 kids
Child: pid=0; NOPATH=\\XLBEARA01M\d$\apps\oraforms\NET80\ADMIN\tnsnames.ora
Parent: Child -3568 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: I have 2 kids
Parent: Child -11440 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: I have 3 kids
Child: pid=0; NOPATH=\\XLBEARA01M\e$\oracle\ora81\network\ADMIN\tnsnames.ora
Child: pid=0; NOPATH=\\XLBEARF01M\d$\apps\oracle\network\ADMIN\tnsnames.ora
Parent: Child -544 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: waitpid '-544'
Parent: I have 4 kids
Child: pid=0; NOPATH=\\XLBEARF01M\d$\apps\oraforms\NET80\ADMIN\tnsnames.ora
Parent: Child -10592 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: waitpid '-544'
Parent: waitpid '-10592'
Parent: I have 5 kids
Child: pid=0; NOPATH=\\XLBEARF01M\e$\oracle\ora81\network\ADMIN\tnsnames.ora
Parent: Child -10344 Started
Parent: waitpid '-6796'
Parent: waitpid '-3568'
Parent: waitpid '-11440'
Parent: waitpid '-544'
Parent: waitpid '-10592'
Parent: waitpid '-10344'
Parent: I have 6 kids
--
You can see that it catches the first child thread (-11404) dying... but all subsequent children are not caught... is it that this script is processed as a cgi that it's not handling the thread signals properly?
Thanks,
Andy Speagle
-----
On 4/26/06, $Bill Luebkert <[EMAIL PROTECTED]> wrote:
Andy Speagle wrote:
> 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:
Personally, I would never use fork on windoze since it's not implemented
in the OS. I would opt for using Win32::Process instead or just multiplex
all the code in a single process. You could also try using threads, but
could end up with similar results since they don't seem to be any more
solid than the fork emulation (judging by problem posts).
> The @arrServerChecks array simply contains a list of UNC paths...
See if this makes any differrence on your fork implentation :
use strict;
use warnings;
use POSIX;
my @kids;
# correct the line below to your UNC paths (or replace):
my @arrServerChecks = ('1', '2', '3', '4', );
while (1) {
if (my $strPath = shift @arrServerChecks) {
my $pid = fork ();
push @kids, $pid;
die "Can't fork: $!" unless (defined ($pid));
# if child
if (!$pid) {
if (-e $strPath) {
print "<BR>Child: pid=$pid; path=$strPath\n";
print NAMEFILE "$strPath\n";
} else {
print "<BR>Child: pid=$pid; NOPATH=$strPath\n";
}
exit;
}
print "<BR>Parent: Child $pid Started\n";
}
my @newkids;
foreach my $child (@kids) {
print "<BR>Parent: waitpid '$child'\n";
if (waitpid ($child, WNOHANG) == $child) {
print "<BR>Parent: Child $child Died ($?)\n";
} else {
push @newkids, $child;
}
}
@kids = @newkids;
print "<BR>Parent: I have " . scalar (@kids) . " kids\n";
last if not @kids;
sleep 1;
}
__END__
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
