Re: [algogeeks] problem of fork()

2012-05-24 Thread sumit mahamuni
its not about compilers ... its that new kernels kills all the child processes, if parent gets killed before.. so that is the reason you are gettin diff reasons On 5/24/12, himanshu kansal wrote: > i know that the program sholud have printed "hello word" 8 timesbt whn > i run it, i get diffrn

Re: [algogeeks] problem of fork()

2012-05-24 Thread Srikrishan Malik(gmail)
because the process which is executed from prompt has exited and the children are still alive and printing. On Thu, May 24, 2012 at 8:26 AM, Rajesh Kumar wrote: > #include > main() > { > fork(); > fork(); > fork(); > printf("Hello Word\n"); > } > > output --- > rajeshkumar@rajeshkumar-laptop:~$

Re: [algogeeks] problem of fork()

2012-05-24 Thread sumit mahamuni
arey Dude before child process gets killed, your parent gets killed and it returns to shell On Thu, May 24, 2012 at 8:26 AM, Rajesh Kumar wrote: > #include > main() > { > fork(); > fork(); > fork(); > printf("Hello Word\n"); > } > > output --- > rajeshkumar@rajeshkumar-laptop:~$ ./a.out > Hello W

Re: [algogeeks] problem of fork()

2012-05-23 Thread himanshu kansal
i know that the program sholud have printed "hello word" 8 timesbt whn i run it, i get diffrnt reslts everytime and on diffrnt compilers... please tell the reason On Thu, May 24, 2012 at 11:11 AM, rajesh singarapu wrote: > main process have completed till the time all processes proces

Re: [algogeeks] problem of fork()

2012-05-23 Thread rajesh singarapu
main process have completed till the time all processes processes prints Hello World, to prevent it, use wait/wait4 family of fucntions. ~r On Thu, May 24, 2012 at 8:26 AM, Rajesh Kumar wrote: > #include > main() > { > fork(); > fork(); > fork(); > printf("Hello Word\n"); > } > > output --- > r

[algogeeks] problem of fork()

2012-05-23 Thread Rajesh Kumar
#include main() { fork(); fork(); fork(); printf("Hello Word\n"); } output --- rajeshkumar@rajeshkumar-laptop:~$ ./a.out Hello Word Hello Word Hello Word rajeshkumar@rajeshkumarr-laptop:~$ Hello Word Hello Word Hello Word Hello Word Hello Word Why it is not printed continously? -- You received