http://qs1969.pair.com?node_id=145512

c has asked for the wisdom of the Perl Monks concerning the following question:

i wrote this a short while back as i started down the path of trying to understand wait. i think i've got a pretty good handle on how it works, and the idea that you really need to wait for each child process, or at least until they all close. in a response to my previous post, bluto offers a suggestion on how to handle the problem by incrementing a variable for each child process spawned and then waiting in a while loop as the variable is decremented. That makes sense to me, or at least the "how it works" makes sense.
I found this code, which seems to work as well, and really does not let the parent pid exit until all children are through as evidenced by the command line not returning until all children run through. however i'm not really certain just *how* it works

## wait on chid processes to exit while (wait() != -1) { return 1 if ($?); }

i see that return will return a value of 1 if there is a child process error held in $?, however the condition of the while is what confuses me. wait not equal to -1. so in one line its waiting, but checking on a value, and i am not sure where the value is coming from.

mad thanks! -c