Fork system call : <p>i tried to execute the following code in c :</p>

<pre><code>#include &lt;stdio.h&gt;
#include  &lt;string.h&gt;
#include  &lt;sys/types.h&gt;
int main()
{
int pid;
pid = fork ();
printf ("%d \n", pid());
           }
</code></pre>

<p>I'm getting the following result : </p>

<pre><code>17601 
0 
</code></pre>

<p>The var pid should store the value of the process id right ?!</p>

<p>so which of the following is the parent and which is the child's id ?! 
to be more specific i want to know what does the return value of the fork() system call ?! and why is it 0 in one of these processes ?! </p>

<p>another question , does this output always the same ?! or could it be inverted sometimes ?! </p>

<p>Kind regards </p>
