简体   繁体   中英

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? 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.

In Unix, the process will continue and run as a subprocess of 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM