title: How to fork n children and have them execute different tasks in C?
body: <p>I'm trying to create 4 children processes from a parent and have each child execute something different.</p>
  
  <pre><code>int main(void) {
  int processes = 4;
  int i;
  for (i = 1; i &lt;= processes; i++) {
      if (fork() == 0) {
          printf("pid: %d\n", getpid());
          exit(0);
      }
  }
  int status;
  for (i = 1; i &lt;= processes; i++)
      wait(&amp;status);
  }
  </code></pre>
  
  <p>Right now the output produces
      pid: 5847
      pid: 5846
      pid: 5845
      pid: 5844</p>
  
  <p>Why are the pid's in decreasing rather than increasing orders? Am I not correctly using the fork() to create the children?</p>