Dear All,
I've been banging my head on this one for a while, so I thought I would beg
for your help.
I have written a perl script that should fork in to several different
processes (8). Part way through this script, the parent process of these 8
sleeps for a period, wakes up, and kills any of the 8 processes that are
still running.
What actually seems to happen is that all 9 processes (the 8 kids and the
parent) all sleep at the same time, all wake up at the same time, and hence
the child processes never have time to do their work.
Is there anything I can do to prevent this behaviour???
I'm running apache 1.3.19, mod-ssl and perl version 5.005_03 built for
i586-linux. The perl code mutithreads correctly when run as stand alone.
I would be extremely grateful if you could reply by email.
Thanks in advance,
Paul
Code follows :
#!/usr/bin/perl -w
# pipe1 - use pipe and fork so parent can send to child
use IO::Handle;
use strict;
use POSIX ":sys_wait_h";
require "/usr/local/httpd/cgi-bin/whois_library";
pipe(PARENT_RDR, CHILD_WTR);
pipe(CHILD_RDR, PARENT_WTR);
CHILD_WTR->autoflush(1);
PARENT_WTR->autoflush(1);
my @array= &get_domain_alternative("blogssss.com");
my @not_registered;
my @pid_array;
foreach my $domain (@array)
{
print "spawning child for domain : $domain\n";
if (my $pid = fork)
{
print CHILD_WTR "$domain\n";
# waitpid($pid,&WNOHANG);
print "*1*$domain\n";
push(@pid_array, $pid);
} else {
die "cannot fork: $!" unless defined $pid;
chomp(my $line =