Weird behavior of parent and child in fork
<p>After the execution of the below code, the root command line does not appear automatically. If the sleep statements are reversed, then the root command line is displayed.</p>

<p>Why this behavior?</p>

<pre><code>#include&lt;stdio.h&gt;
#include&lt;unistd.h&gt;
int main()
{
    if(fork()==0)/*creating fork*/
    {
        sleep(10);
        printf("In child.. %d.\n",getpid());
    }
    else
    {
        sleep(5);
        printf("In parent.%d ..\n",getpid());
    }
}
</code></pre>