in reply to Re^2: Check if forked process is dead
in thread Check if forked process is dead

You cannot avoid race conditions in such a quest ...