Now, this seems to be working properly, as I get all my data just fine. But now I've added something new to each of the called perl programs, a sub-call to another program. The line in each program will look like:$| = 1; $pid = open(first_child, "-|"); if ($pid) { while(<first_child>) { if ($_ =~ m/^Error/) { } #do nothin elsif ($_ =~ m/^Hits/) { push (@hits, $_) ; } else { push (@line, $_); } } } else { my (@child, @cpic); foreach $i(0..@gets) { $e = $gets[$i]; $c = $searches{$e}{handler}; $p = $FORM_DATA{p}; $q = $FORM_DATA{q}; $u = $searches{$e}{url}; $caller = "perl $c $p $q $u"; $cpid[$i] = open($child[$i], "|-"); if ($cpid[$i]) { } # do nothing else { system ($caller); exit; } } foreach (@child) { close($_); } exit; }
The program makemore.pl seems to work just fine as it is. My problem is with data being pushed to the @hits array. It seems that when I comment out the perl call in the called programs, I get all my data in @hits just fine. But, with the line activiated, I'm getting some problems with some of the called programs not pushing their data into @hits.$more = 'perl makemore.pl "$words" "$keywords"';
This would be annoying enough, but the problem seems to be unrelated to anything I can see. As the processes are split off, their running time may vary. As such, the order of the results being returned may not always be the same. Another problem is that if I run just one sub-process in the loop above, it does work ok. In fact, I can sometimes run multiple sub-calls. The problem is that in some cases, running multiple sub-calls seems to blow away that one piece of the data. Other data from the sub-calls do come back just fine.
Addendum:
This is no longer a 2-pipe situation, as I've made the change to forking the the child processes off from the first pipe.
Other ideas in here I have tried, but they don't provide any further help. ForkManager isn't an option, as we don't have it installed here.
Also, when I set $| = 1; I can see the output as it forms line by line. I can see that it's taking a second or 2 to generate the lines of output from @hits. But even then, it's still managing to skip one.
Read This !!!: After significant debugging with the help of someone who is much more foo in those ways than I, it has been discovered that the smashing up of my output has come from corrupted data, nothing more. So, I thank all of you who have given input. In the end, my coding will be better for this. And I have a few new ideas to mull over in my head. End result, the entire process is being redesigned almost completely from scratch to hopefully better account for the poorly formated data.
Again, thanks to all who have responded, please don't hate me for this. :)
In reply to Processes clobbering each other by mcogan1966
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |