I wrote a simple example of fork()
like below:
#include <sys/types.h>
void main()
{
printf("Stack overflow\n");
pid_t p = fork();
if ( p )
printf("I am parent\n");
else
printf("I am child\n");
return 0;
}
Ideally, "Stack overflow" should be printed only once but at my end the string is printed twice. I am unable to understand it. Can anyone help?