Hi all,<br>I have been trying to create a process using vfork(). And both of the child and the parent process execute it in the same address space. So, if I execute exit(0) in the child process, it should throw some error right. Since the execution is happening in child process first and if I release all the resources by using exit(0) in the child process then parent should be deprived of the resources and should throw some errors right ?? <br>
In the following code, however the process ran fine even though I have exit(0) in the child process ........<br>#include<stdio.h><br>#include<stdlib.h><br>#include<sys/types.h><br>#include<unistd.h><br>
int main()<br>{<br> int val,i=0;<br> val=vfork();<br> if(val==0)<br> {<br> printf("\nI am a child process.\n");<br> printf(" %d ",i++);<br> exit(0);<br> }<br> else<br>
{<br> printf("\nI am a parent process.\n");<br> printf(" %d ",i);<br> }<br> return 0;<br>}<br>// The program is running fine ..... <br>But as I have read it should throw some error right ?? I don't know what I am missing . Please point out the point I'm missing. Thanking you in advance. <br>