#include<unistd.h>
main()
{
if(vfork() ==0)
{
printf(“This is the child process\n”);
}else{
printf(“This is the parent process\n”);
}
}
main()
{
if(vfork() ==0)
{
printf(“This is the child process\n”);
}else{
printf(“This is the parent process\n”);
}
}
这段代码编译运行完,在最后报了一个segment fault 的错误,在最后加上exit(1)就没报了, 为何呢?
还不明原因
#include<unistd.h>
main()
{
if(vfork() ==0)
{
printf(“This is the child process\n”);
}else{
printf(“This is the parent process\n”);
}
main()
{
if(vfork() ==0)
{
printf(“This is the child process\n”);
}else{
printf(“This is the parent process\n”);
}
exit(1);
}
}
相关热门文章
给主人留下些什么吧!~~
评论热议