title: Interactive shell stop pipe
body: <p>My program is as follow:</p>
  
  <pre><code>//... init fd[2] as pipe ...
  if (child==0){
          close(fd[1]);
          dup2(fd[0], 0);
          execlp("/bin/sh","sh",NULL);
  } else {
          close(fd[0]);
          char *line; int nbytes=100; int bytes=0;
          line=(char*) malloc(nbytes+1);
          while ( (bytes = getline((char **)&amp;line,&amp;nbytes,stdin))!= -1 ){
              write(fd[1],line, bytes);
          }
  }
  </code></pre>
  
  <p>This run OK, however when I try to replace <code>exec("/bin/sh","sh",NULL)</code> with <code>exec("/bin/sh","sh","-i",NULL)</code> to force an interactive shell, my program stop after executing the first command.</p>
  
  <p>I'm new to pipe so please help me understand the reason and make interactive shell work... I also feel that my code to read line and pass to the child pipe is a bit odd.. is there any better way to achieve the same behavior ?</p>