title: Pipe not sending accurate information
body: <p>I have started using pipe for a basic exercise. From processes A and B we get 2 random numbers. Process C does the sum of these 2 numbers and it prints it. 
  The problem is that I don't get the correct values from reading. The values that enter in the pipe are not the ones that exit.</p>
  
  <p>What is the problem here?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/wait.h&gt;
  
  
  int main(){
  
      int ac[2],bc[2];
      int f,g;
      if(pipe(ac)&lt;0 || pipe(bc)&lt;0){
          perror("Pipe error");
          exit(1);
      }
  
      f=fork();
  
      if(f&lt;0){
          perror("Error fork1");
          exit(2);
      }
      if(f==0){
          g=fork();
          if(g&lt;0){
              perror("Error fork2");
              exit(3);
      }
      if(g==0){
              printf("We are in  A \n");
              int variab=rand()%11+10;
              printf("Here we found the number %d\n",variab);
              write(ac[1],&amp;variab,sizeof(int));
      }   
      else{
              wait(0);
              printf("We are in B\n");
              int variab2=rand()%6+5;
              printf("Here we found the number %d\n",variab2);
              write(bc[1],&amp;variab2,sizeof(int));
      }
      }
      else{
          wait(0);
          printf("We are in C\n");
          int suma;
          int s1=read(ac[0],&amp;s1,sizeof(int));
          printf("S1=%d\n",s1);
          int s2=read(bc[0],&amp;s2,sizeof(int));
          printf("S2=%d\n",s2);
          suma=s1+s2;
          printf("Sum is %d\n",suma);
      }
      close(ac[0]);
      close(ac[1]);
      close(bc[0]);
      close(bc[1]);
      return 0;
  }
  </code></pre>