杀死进程和subprocess,而不是父进程,而不是组

我需要以编程方式杀死一个进程及其所有subprocess。

杀死该组不是一个选项,因为我不想杀死父进程。

例:

pid process 1 nice parent process that should live 2 subprocess of 1, but a nice one, should live 3 subprocess of 1, evil one, should die 4 childprocess of 3, inherite evil, should die 5 childprocess of 3, inherite evil, should die 6 childprocess of 5, inherite evil second line, should die kill --some-cool-option 3 

我不认为有一个像简单的kill命令一样简单的解决scheme。

我对这个问题的答案可能会有所帮助: https : //stackoverflow.com/questions/30980234/linux-the-most-reliable-way-to-terminate-a-family-of-processes/31004557?noredirect=1#comment50067451_31004557 。