title: fork() used as for cycle condition generates race condition?
body: <p>alright so here is an excersise we had on today's exam of operating systems</p>
  
  <p>given this program in C</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  
  int  main(){
      int i;
      for(i=2;i&gt;=1&amp;&amp;!fork();i--)
              printf("%d\n",i);
  
  exit(EXIT_SUCCESS);
  }
  </code></pre>
  
  <p>executing it give this output :    </p>
  
  <pre><code>2
  1
  </code></pre>
  
  <p>What I've found ambiguous is how the index "i" is managed by the program
  and what would be the correct order in wich the processes execute 
  (if there is an order or it's a random order estabilished by the scheduler ?)</p>
  
  <p>And why there are only 2 and 1 printed - My assumptions are :</p>
  
  <pre><code>(father executes the "for" only for i=2, prints 2 then exits ?)
  (the first child starts from i=1 forks a child prints 1 exits ?)
  </code></pre>
  
  <p>At this point my question is : </p>
  
  <p>Is there a second child forked that doesn't enter the for ? 
  and is 2 printed by father and 1 by the first child ?</p>
  
  <p>And one final thing : </p>
  
  <p>How would you rewrite this fork-conditioned-for to get it more readable (eg. an if-statement)</p>