in reply to child processes in fork

wait till all the children are finished

Use wait (if it returns -1, then you have no childs left).