How can I cause a child process to exit when the parent does?

后端 未结 9 2036
一生所求
一生所求 2020-11-27 16:07

I am launching a child process with ProcessBuilder, and need the child process to exit if the parent process does. Under normal circumstances, my code is stopping the child

9条回答
  •  孤街浪徒
    2020-11-27 16:31

    As I tested, if the parent is killed, then the ppid of a child will become 1. So probably we can kill any processes that have ppid = 1.

提交回复
热议问题