title: getting child process ID from the parent using C
body: <p>I'm trying to write a C program where I have one parent that create two childs.</p>
  
  <p>My task is to retrieve the process ID of the parent of and both childs. For this I've been using <code>getpid()</code>.</p>
  
  <p>Now I've been asked to get the child information from the parent. I don't get how I can do this. Like how can I obtain the processing ID for a child from the parent?</p>
  
  <p>I have this at the moment (simplified)</p>
  
  <pre><code>fork1 = fork();
  
  if (fork1 &lt; 0)
      fork error
  else if (fork1 == 0) {
      child 1
      use getpid()
      use getppid()
  } else {
      fork2 = fork();
  
      if (fork2 &lt; 0)
          fork error
      else if (fork2 == 0) {
          child 2
          use getpid()
          use getppid()
      } else 
          parent again
  }
  </code></pre>