title: How can I write twice on the same pipe?
body: <p>I want parent to read from standard input and write it on pipe then the child read from this pipe and convert it to upper case and send it back on another pipe to the parent then the parent print it on standard output then write more one time.</p>
  
  <p>The parent doesn't write anthor time</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;dirent.h&gt;
  #include &lt;string.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;unistd.h&gt;
  #define bufsize 200
  
  int main(int argc,char*argv[])
  {
      char buf[bufsize];
      char buf2[bufsize];
      int x;
      int child;
      int fd[2];
      int fd1[2];
      int nbytes,mbytes;
      int i,j,k;
      int status=0;
  
      if(pipe(fd)==-1)
          printf("pipe");
      if(pipe(fd1)==-1)
          printf("pipe");
  
      switch(fork())
      {
          case -1 : printf("fork");
          case 0:{
              //for(k=1;k&lt;3;k++)
              //{close(fd[1]);
              nbytes = read(fd[0], buf, bufsize);   
  
              for(i=0;i&lt;=strlen(buf);i++){
                  if(buf[i]&gt;=97&amp;&amp;buf[i]&lt;=122)
                  buf[i]=buf[i]-32;
              }//end for
  
              close(fd1[0]);
              write(fd1[1], buf, nbytes);
              _exit(EXIT_SUCCESS);   
  
          }//end child
  
          default:{
              for(j=1;j&lt;3;j++){
                  close(fd[0]);
                  printf("Enter any thing:\n");
                  x=read(STDIN_FILENO, buf, bufsize);
                  write(fd[1],buf,x);
  
                  close(fd1[1]);
                  mbytes = read(fd1[0], buf, bufsize);   
                  close(fd1[0]); 
                  write(STDOUT_FILENO, buf, mbytes);
              }
              //wait(status);
              exit(EXIT_SUCCESS);
          }//end default
      }//end switch
  }
  </code></pre>