运行下列程序,子进程中对X重新赋值对父进程有什么影响?

#include<stdio.h>

main()

{

  int p1;

int x=1;

while((p1=fork())==-1);

if(p1==0)

{

 putchar('b');

x=9;

printf("%d",x);

}

 else

{

 

 putchar('a');

printf("%d",x);

}

}

没有影响。

fork完后,父子进程分别有自己的(虚拟)内存地址空间,栈、堆都是独立的。父子进程通信就要用socket, shared memory, files等。