in reply to Child PID?

Why are you incrementing $child? When you call fork from the parent, the return _is_ the child's pid. If you call fork from inside the child, the return is zero. That's how a script knows if it is the parent or the child process.