#include #include #include #include int x; int main() { pid_t prid; // process id. x = 3; printf("in main:\n"); prid = fork(); // fork child process // prid == 0 if you're child process, otherwise prid== pid of child if (prid == 0) // i'm child { x++; printf("I'm the child, x==%d\n",x); } else // i'm parent { x++; printf("I'm parent, x==%d\n",x); } exit(0); }