In our last episode, the evil Dr. Lacto had captured our hero,
"trxrse" <>, who said:
>I have a piece of code and I really don't understand what's
>happening...
Found it.
>print "Parent continues now...\n";
># Parent - wait for returned data
>while (&sum_pids > 0) {
> print "sum_pids=",&sum_pids,"\n";
> while (! $gotone){
> sleep 1;
> print "Slept 1\n";
> }
> $gotone=0;
> print "finished_child=$finished_child","\n";
> foreach (@kids){
vvvvv
> if ($finished_child=$_){
^^^^^
> print "\$finished_child=",$finished_child,"\n";
> print "\$_=",$_,"\n";
> print "I am the parent and process $_ finished!!!\n";
> $_=0;
> }
> }
>}
As soon as you finish your first child, you declare them all finished.
Thus the while loop only runs once.
hymie!
http://www.smart.net/~hymowitz
================================================== =============================
When speaking to a Bear of Very Little Brain, remember that long words may
Bother him. -- Winnie the Pooh
================================================== =============================