The following two codes are compiled and executed using the gcc compiler code1:
main()
{
printf("Before FORK\n");
fork();
printf("After FORK \n\n");
}
code 2:
main()
{
printf("Before FORK");
fork();
printf("After FORK \n\n");
}
The code1 prints "Before FORK" statement once but the code2 prints the same twice. Please explain the reason behind that.