fork() branches more than expected?

Consider the following piece of code:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main(void)
{
    int i;
    for(i = 0; i < 2; i++)
    {
        fork();
        printf(".");
    }
    return 0;
}

This program outputs 8 dots. How can that be possible? Should not there be 6 dots instead?

3 Answers
3

Leave a Comment