I\'m not understanding the output of this program:
#include #include #include int i = 0; int main() {
Change your code to this and the output should make a lot more sense:
#include #include #include int i = 0; int main() { while (i < 3) { fork(); printf("pid = %d, i = %d\n", getpid(), i); ++i; } return 0; }