Blog Archive

How many processes will be created-- fork?

sandesh@nextfour:~/labs> cat fork.c
#include
#include
#include

int count;
main()
{
int i;
for(i=0;i<3;i++)
fork();
count++;
printf("Hello %d\n",count);
}
sandesh@nextfour:~/labs> gcc fork.c
sandesh@nextfour:~/labs> ./a.out
Hello 1
Hello 1
Hello 1
Hello 1
Hello 1
Hello 1
Hello 1
Hello 1
sandesh@nextfour:~/labs>

No comments: