Use wait (if it returns -1, then you have no childs left).
In reply to Re: child processes in fork by cog in thread child processes in fork by Anonymous Monk