代码中已经出现了一个fork:
if (pid == 0) {
printf("I am child PID %d\n", getpid());
exit(EXIT_SUCCESS);
} else {
pid_t child;
int status;
//need wait() function that gets child pid and exit status
printf("Child PID %d terminated with return status %d\n", child, status);
}
如代码中所述,我需要一个适当的等待函数,它将等待子节点结束并获取子节点的PID和结果退出状态代码。谢谢!