作業系統›Ch4 行程與執行緒管理
第 46 題/共 70 題
◀ OS 46/70
46. Orphan Process、fork()
#OS-04-046易Orphan Processfork()

(8%) An orphan process is a process whose parent process no longer exists, i.e., either it has finished or terminated without waiting for its child processes to terminate. Please finish the following code within the box, which can create an orphan process.

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main ()
{
    int pid = fork();
    if (pid > 0)
    {
        // this is parent process
        ____________
    }
    else if (pid == 0)
    {
        // this is child process
        ____________
    }
    return 0;
}
📄 成大115
跳轉到第題
▤完整推導請見《WH 資工筆記 · 作業系統》Ch4 行程與執行緒管理
本章題號 · 41–60 / 70