wen u do frok in ur code, the pr gets duplicated. so that line wher fork is
invoked is also in both the processes. nw in parent code it will return pid
of child & in child code it will return 0.

getpid will always return the pid of the pr. so obviously it will return pid
of the child in the child pr.

is it clear ..

On Sun, Oct 2, 2011 at 5:01 AM, rahul sharma <[email protected]>wrote:

> pid=0 for child
> then getpid in child???gives child process id???plz xplain
>
>
> On Sun, Oct 2, 2011 at 1:32 PM, rahul vatsa <[email protected]> wrote:
>
>> child contains full code, bt it will start execution of the next line
>> after the fork.
>> return value of fork is 0 for the child, bt pid of the child in the parent
>> process.
>>
>>
>> On Sun, Oct 2, 2011 at 3:50 AM, rahul sharma <[email protected]>wrote:
>>
>>> plz tell me hw does fork wokrs???child contain full code ore the
>>> statements after fork????hw pid is 0 with pi=fork();
>>> i cant get these..plz tell asap...thnx
>>>
>>> On Oct 2, 12:49 pm, rahul sharma <[email protected]> wrote:
>>> > main()
>>> > {
>>> > int pid;
>>> > pid=fork();
>>> > if(pid==0)
>>> > {
>>> > print child;
>>> > print("...",getpid());}
>>> >
>>> > else
>>> > {
>>> > print print;
>>> > print("...",getpid());
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > }
>>>
>>> --
>>> 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.
>>>
>>>
>>  --
>> 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.
>>
>
>  --
> 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.
>

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