xv6-chinese
xv6-chinese copied to clipboard
关于第0章中代码的疑问。
在第0章第一段关于fork()
的代码中
int pid;
pid = fork();
if(pid > 0){
printf("parent: child=%d\n", pid);
pid = wait();
printf("child %d is done\n", pid);
} else if(pid == 0){
printf("child: exiting\n");
exit();
} else {
printf("fork error\n");
}
按照此代码写出的程序,运行结果为
parent: child=3610
child: exiting
child -1 is done
将其中的 wait()
修改为 wait(NULL)
后,结果正确。
我真实遇到这个问题了,新手,google了很多才解决掉。不知道是我操作错误,还是真的存在这个问题。
底子不够扎实
发自网易邮箱大师 在2017年02月21日 14:57,neil-chennn 写道:
我真实遇到这个问题了,新手,google了很多才解决掉。不知道是我操作错误,还是真的存在这个问题。
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.