请绘制此fork代码的进程树 [英] Please draw the process tree for this fork code
本文介绍了请绘制此fork代码的进程树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdio.h>
#include <unistd.h>
main()
{
int ii=0;
if (fork() > 0) ii++;
wait(NULL);
if (fork() == 0) ii++;
wait(NULL);
if (fork() < 0) ii++;
wait(NULL);
printf ("Result = %d \n",ii);
}
我的尝试:
i试图为这个人下载一个应用程序,但我没有找到。
What I have tried:
i tried to download an application for this person but i didn't find.
推荐答案
主要进程将分叉三次:
- 第一个分叉本身会分叉两次。
- 第二个分叉本身会分叉一次。
- 第三个分叉将不再分叉。
The main process will be forked three times:
- The first fork will be itself forked two times.
- The second fork will be itself forked one time.
- The third fork will not be forked anymore.
Nope。我们不是来为你工作。
Nope. We're not here to do your work for you.
这篇关于请绘制此fork代码的进程树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文