1 #include "apue.h" 2 3 int globvar = 6; 4 5 int main(void) 6 { 7 int var; 8 pid_t pid; 9 10 var = 88; 11 printf("before vfork "); 12 if((pid = vfork()) < 0){ 13 err_sys("vfork error"); 14 }else if(pid == 0){ 15 globvar++; 16 var++; 17 _exit(0); 18 } 19 20 printf("pid = %ld,glob = %d,var = %d ",(long)getpid(),globvar,var); 21 22 exit(0); 23 }