Hi and thanks for the reply.
I have written the same code as your example, with -1 as the pid parameter to waitpid. So i think i am waiting for every child to die.
The problem is that when a child dies, the child_handler routine runs, but if another child dies at the same time that the routine is handling the previous child, the last death is ignored (i.e the program counter is on the handler routine already). I dont want to ignore children return codes and simply prevent zombies. I want to know if everything i spawned is running/has exited