#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
//进程间全局变量数据共享
int i = 200;
int main(int argc,char *argv[])
{
pid_t pid;
pid = fork();
//father process
if(pid > 0)
{
i += 400;
printf("this is father process %d\n",getpid());
printf("i = %d\n",i);
}
//child process
else if(pid == 0)
{
i += 200;
printf("this is child process %d,ppid is %d\n",getpid(),getppid());
printf("i = %d\n",i);
}
return 0;
}