I read somewhere that in Unix, after fork() is executed successfully, both processes will start their execution at the next statement following the fork() call. Meanwhile when I run this code in C
#include <stdio.h>
int main()
{
printf(" do ");
if(fork()!=0) printf ("ma ");
if(fork()==0) printf ("to \n");
else printf("\n")
return 0;
}
one possible output is
do ma
do ma to
do
do to
"printf(" do ");" is before the fork() call so how comes "do" is repeated several times in the output?