How to keep track of all descendant processes to cleanup?

后端 未结 2 1430
慢半拍i
慢半拍i 2021-02-15 10:58

I have a program that can fork() and exec() multiple processes in a chain. E.g.: process A --> fork, exec B --> fork, exec C --> fork, exec D. So A i

2条回答
  •  执笔经年
    2021-02-15 11:31

    The POSIX way to do this is simply to use process groups. Descendant processes that explicitly change their process group / session are making a deliberate decision not to have their lifetime tracked by their original parent - they are specifically emancipating themselves from the parent's control. Such processes are not orphans - they are adults that have "flown the nest" and wish to exert control over their own lifetime.

提交回复
热议问题