in reply to parenticide...

What you can do is only have the parent take out the children. The parent process forks off the children, and then wait()'s until one of the children die's. Then it kills all of its children. One advantage is that the parent can keep track of the children pid's and doesn't need to kill the process group.

If you need to have the parent do some processing, the parent could do the killing in a SIG{CHLD} handler. You would need to worry about race conditions since the killed children will produce CHLD signals.

BTW, I think your code doesn't work because kill() sends the signal to process group when the signal is negative, not the process id. The documentation says that negative process numbers only work on SysV-based systems.

Replies are listed 'Best First'.
Re: Re: parenticide...
by jca (Sexton) on Nov 28, 2002 at 10:02 UTC
    Thanks for everyones input. I have managed to make it behave by using getppid in the child thread and signalling that pid - I am also using waitpid in the parent process to make sure that all the children finish doing what they are supposed to...and to try to keep a lid on the zombies...

    well he certainly looks dead...