fork_1.c

来自「工ARM_LINUX的几个源代码」· C语言 代码 · 共 19 行

C
19
字号
/*fork two child progress*/
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
int main()
 {
pid_t child;
pid_t child1;
  child=fork();
if (child==0){
   printf("this is child progress 1....child1 pn is %dparent pn is %d\n",getpid(),getppid());}
if (child>0){
   printf("this is parent progress 1.... pn is %d\n",getpid());
   child1=fork();
   if (child1==0){
   printf("this is child progress 2....child2 pn is %dparent pn is %d\n",getpid(),getppid());}
   }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?