@jitendra u got it right but parent and child are using the same text region
that's why control is transferring back and forth..
try running this code and see that line numbers are repeating...because of
same text region it is working like a loop...
#include<stdio.h>
int main() {
int id,i;
if((id=vfork())==0) { //child
printf(" %d in child\n",__LINE__);
sleep(3);
printf("%d\n",i);
}
else { //parent
printf(" %d in parent\n",__LINE__);
scanf("%d",&i);
sleep(1);
printf("%d\n",i);
}
return 0;
}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.