title: How to make parent wait for all child processes to finish?
body: <p>I'm hoping someone could shed some light on how to make the parent wait for <em>ALL</em> child processes to finish before continuing after the fork. I have cleanup code which I want to run but the child processes need to have returned before this can happen.</p>
  
  <pre><code>for (int id=0; id&lt;n; id++) {
    if (fork()==0) {
      // Child
      exit(0);      
    } else {
      // Parent
      ...
    }
    ...
  }
  </code></pre>