title: Pass the value from child to parent process
body: <p>I have this code that is supposed to create three child process' and each will perform a small mathematical operation. Then, the parent is supposed to use the results from all the child process' and get a final answer but I can't find a way to actually read the result from the child in the parent. Is there a way to do this?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void)
  {
     int pid1, pid2, pid3, status;
     int a=1, b=2, c=5, d=4, e=6, f=3, g;
     int t1, t2, t3;
  
     printf("Hello World!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
     printf("Here I am  before use of forking\n");
     printf("I am the PARENT process and pid is : %d\n",getpid());
  
     pid1 = fork( );
     if (pid1 == 0)
     {      
      printf("\n\nHere I am just after child forking1\n");
      printf("I am the Child process and pid1 is :%d\n",getpid());      
      printf("My parent's pid is :%d\n",getppid());   
      t1 = a+b;
      printf("The answer for t1 is: %d\n", t1);       
      exit(0);
     }
     else
     {
      wait(&amp;status);
          printf("\nHere I am just after parent forking1\n");
          printf("I am the Parent process and pid is: %d\n",getpid());
     }
  
     pid2 = fork( );
     if (pid2 == 0)
     {      
      printf("\n\nHere I am just after child forking2\n");
      printf("I am the Child process and pid2 is :%d\n",getpid());      
      printf("My parent's pid is :%d\n",getppid());   
      t2 = c+d;
      printf("The answer for t2 is: %d\n", t2);   
      exit(0);    
     }
     else
     {
      wait(&amp;status);
          printf("\nHere I am just after parent forking2\n");
          printf("I am the Parent process and pid is: %d\n",getpid());
     }
  
     pid3 = fork( );
     if (pid3 == 0)
     {      
      printf("\n\nHere I am just after child forking3\n");
      printf("I am the Child process and pid3 is :%d\n",getpid());      
      printf("My parent's pid is :%d\n",getppid());   
      t3 = e/f;   
      printf("The answer for t3 is: %d\n", t3);   
      exit(0);
     }
     else
     {
      wait(&amp;status);
          printf("\nHere I am just after parent forkingALL\n");
          printf("I am the Parent process and pid is: %d\n",getpid());
     }
  
  
     printf("\n\nThe final answer for t1 is: %d\n", t1);
     printf("The final answer for t2 is: %d\n", t2);
     printf("The final answer for t3 is: %d\n", t3);
  
  
     g = t1*t2-t3;
     printf("The final answer for g is: %d\n", g);
  }
  </code></pre>