On Sun, Jun 6, 2010 at 12:04 PM, Jitendra Kushwaha <[email protected]
> wrote:

> #include<stdio.h>
> int main() {
>        int id,i;
>
>        if((id=vfork())==0) {           //child
>                printf("in child\n");
>                sleep(3);
>                printf("%d\n",i);
>        }
>        else {                          //parent
>                printf("in parent\n");
>                scanf("%d",&i);
>                sleep(1);
>                printf("%d\n",i);
>        }
>        return 0;
> }
>
>
you have opted for vfork so child will execute then parent .So o/p will be
like

in child
(garbage value of i)
in parent
(scanf) i
print i




can anybody answer why output of this program going in  loop.
> (tested on  gcc 4.4 compiler)
>
> --
> 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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Thanks & Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science & Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
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.

Reply via email to