in reply to Re: fork...
in thread fork...

I dont think I am understanding your problem now. What do you mean by a 'non-stopped parent'. I think you are saying that the parent 'do' loop never ends so it keeps printing? On my system everything worked beautifully. They parent looped until the child died, then the parent quit the loop and exited. What OS are you using, I am on an SGI irix machine, so there could be differences with the OS handleing of signals and forking. Anomolies in forking/signal handling can be hugely dependant on OS.

Did you try the signal handling example? Since this program is so short I would recommend stepping through the debugger (following the parent) to see what the results of your waitpid function is.

Maybe the waitpid does not return a -1 (it should when all children die. ... you are only forking once?). It should return a 0 when any child dies, so maybe change the logic to
do { ... code here ... } while $child_pid > 0;
This will loop until *any* child dies. (Well on my system it would anyway.)

Another idea (this might be completely false) maybe your child forks again? It might be that if the child process itself becomes a parent, then the grandparent waitpid might not return a -1. I have no idea ... something to consider though.

Hopes this helps. Reply if you get more info.