title: Use two pipes in C or one pipe for more than 2 read/writes? And how?
body: <p>I have the following simplified code template:</p>
  
  <pre><code>pid_t pid;
  int pipe1[2], pipe2[2];
  pid = fork();
  pipe(pipe1); pipe(pipe2)
  if(pid == 0)  //child
  {
      read(pipe1[0],...);
      write(pipe1[1],...);
      close(pipe1[0]);
      close(pipe1[1]);
  
      close(pipe2[1]);
      read(pipe2[0]...);
  }
  else //parent
  {
      write(pipe1[1],...);
      wait(NULL);
      read(pipe1[0]...);
      close(pipe1[0]);
      close(pipe1[1]);
  
      close(pipe2[0]);
      write(pipe2[1]...);
  }
  </code></pre>
  
  <p>If I am not using the pipe2 in parent and child, the code works perfectly, but if I do, it seems like the child has nothing to read(the program does nothing until I intrerrupt it). Also, is there a way to use only one pipe for more than 2 read/writes? I tried using wait(NULL) more than once but that didn't work.</p>