阅读背景:

为什么这个过程之间没有切换

来源:互联网 

I have the following program

我有以下程序

#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
main()
{
    pid_t pid, ppid;
    printf("Hello World1\n");
    pid=fork();
    if(pid==0)
    {

        printf("I am the child\n");
        printf("The PID of child is %d\n",getpid());
        printf("The PID of parent of child is %d\n",getppid());
    }
    else
    {
        while(1)
        {
        printf("I am the parent\n");
        printf("The PID of parent is %d\n",getpid());
        printf("The PID of parent of parent is %d\n",getppid());        

        }
    }
}
#includ



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: