我需要以编程方式终止一个进程及其所有子进程。
终止该组不是一个选择,因为我不想终止父进程。
例子:
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
答案1
我认为没有像简单kill
命令那样简单的解决方案。
我对这个问题的回答可能会有所帮助:https://stackoverflow.com/questions/30980234/linux-the-most-reliable-way-to-terminate-a-family-of-processes/31004557?noredirect=1#comment50067451_31004557。