日期:2014-05-16 浏览次数:20635 次
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int g_a = 1;
int main(void){
int l_b = 1;
pid_t p;
if((p = vfork()) < 0){
perror("fork");
}else if(p == 0){
g_a++;
l_b++;
}
printf("ppid = %d,pid = %d,g_a = %d,l_b = %d\n", getppid(), getpid(), g_a, l_b);
return 0;
}
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int g_a = 1;
int main(void){
int l_b = 1;
pid_t p;
if((p = vfork()) < 0){
perror("fork");
}else if(p == 0){
g_a++;
l_b++;
exit(0);
}
printf("ppid = %d,pid = %d,g_a = %d,l_b = %d\n", getppid(), getpid(), g_a, l_b);
return 0;
}