title: How to get child PID in C?
body: <p>I'm creating child processes in a <code>for</code>-loop. Inside the child process, I can retrieve the child PID with <code>getpid()</code>.  </p>
  
  <p>However, for some reason when I try to store the value of <code>getpid()</code> into a variable declared by the parent process, the change is nullified when I check for it in the parent process.  I'm assuming this has to do with some sort of process variable scope.  Not really familiar with C, so can't be too sure.</p>
  
  <p>Anyhow what is a way of storing the result of <code>getpid()</code> of a child PID (when called from the child process) into a variable in the parent process?</p>
  
  <p>Or maybe another approach is storing <code>fork()</code> into a variable in the parent and calling some function on that variable to retrieve the child's PID? I don't know how to do this either, so if this is the better way, how would you do this?</p>