Consider the following bit of code:
for ($i=0; $i<$g; $i++) {
pipe ($rh, $wh) # both of these are generated in the loop
if ($pid[$i]=fork()) { # parent process
waitpid($pid[$i], 0); # wait for child
close ($wh);
while (<$rh>) { # gimme the output
if ($_ =~ m/^Error/) { push (@error, $_); }
elsif ($_ =~ m^Hits/) { push (@hits, $_); }
else { push (@data, $_); } # each is a result from an engine
}
}
else {
close ($rh);
open (STDOUT, ">&$wh");
open (OUT, "| $caller"); # call the handler with arguments
close (OUT);
exit(0);
}
}
This is part of a multi-headed search engine. The process is to go out to several search engines, poll them for results, and pass them back to the main program. The program is customized to allow from 10-50 results from each search engine. If I say get 10 or 20 from each engine, it works fine. But if I go for 30 or more, it chokes. Is it possible that I'm trying to pull too much through the pipe?
Yes, I know there is stuff missing, but nothing that is relevant to the question at hand. All of that I can't share here.
I should also point out that the idea is to get all the searches to run at the same time so hopefully the entire process will speed up.