This thread should go to Linux programming section!
After you fork(), you have two DIFFERENT processes (not threads). So examining your code
/* you have on process */
/* you have three processes */
printf("I am pid %d!\n", getpid());
The above is a normal fork(),in your program you fork() two times! So, you have one parent and two children. The numbers are PIDs of parent and children processes.
return 0; return 0;
I suggest you to use switch or else-if statements to distingusish the processes.