核心摘要: #include#include#includemain(){ pid_t pid;int n=4; pid=fork(); if(pid0) printf(error in fork!/n);else if(pid==0) { n
#include#include#includemain(){ pid_t pid; int n=4; pid=fork(); if(pid<0) printf("error in fork!/n");else if(pid==0) { n++; printf("I am the child process, my process ID is %d,n=%d/n",getpid(),n); } else { n--; printf("I am the parent process, my process ID is %d,n=%d/n",getpid(),n); }}