> I have a parent process which starts a child process.
> This child process then kicks off some children of its own in the
> background and then terminates.
> I need the parent process to wait until all grandchildren
> are dead but the wait() will only hold until the child terminates
> and not the grandchildren.
> Any Ideas?
> Nigel Foley.
What I think is that the grandchildren become orphans. That is, their
parent dies, so they become inherited by init, whose pid is 1.
Maybe you should make the first child wait for its own children, then
make it terminate after all of the children have died. I have seen in
a book that a common way for a parent that is not interested in the
termination status of its children is to fork twice, i.e. the parent
forks, wait for its child to terminate, then continue processing of
its own. After the fork, the child forks again, then terminates, its
child, the grandchildren of the parent, being orphaned and inherited
Hope this helps.