Are child processes created with fork() automatically killed when the parent is killed?

前端 未结 1 733
礼貌的吻别
礼貌的吻别 2020-11-27 14:47

I\'m creating child processes with fork() in C/C++.
When the parent process ends (or is killed for some reason) I want all child processes to be killed as w

相关标签:
1条回答
  • 2020-11-27 15:46

    No. If the parent is killed, children become children of the init process (that has the process id 1 and is launched as the first user process by the kernel).

    The init process checks periodically for new children, and waits for them (thus freeing resources that are allocated by their return value).

    The question was already discussed with quality answers here: How to make child process die after parent exits?

    0 讨论(0)
提交回复
热议问题