How to keep track of all descendant processes to cleanup?

后端 未结 2 1771
无人及你
无人及你 2021-02-15 10:59

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条回答
  •  -上瘾入骨i
    2021-02-15 11:19

    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.

提交回复
热议问题