[英]In C, if a parent process terminates, then will the child process automatically terminate?
If I use fork()
to spawn a child process, then will the child process automatically terminate once the parent process terminates? 如果我使用
fork()
生成子进程,那么一旦父进程终止,子进程会自动终止吗? Or must this be programmed? 还是必须对此进行编程?
This isn't really ac question, it's an O/S question. 这不是一个真正的交流问题,而是一个操作系统问题。
In Windows, a process will continue until either it calls ExitProcess
or when it has performed enough CPU RETs that there's nothing left in the call stack. 在Windows中,一个进程将继续进行,直到它调用
ExitProcess
或执行了足够的CPU RET,以至于调用堆栈中没有剩余。
In Unix, the process will continue and run as a subprocess of init
. 在Unix中,该过程将继续并作为
init
的子过程运行。
On both O/S's, a user with enough permissions can kill the process. 在两个操作系统上,具有足够权限的用户都可以终止该进程。
Threads, on the other hand, are a different matter-- they will terminate when the process terminates. 另一方面,线程是另一回事-当进程终止时,它们将终止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.