title: execlp stops using socket to send the data
body: <p>i'm creating a program to process some data remote.
  So i use something like</p>
  
  <p>cat file | ./client -i "machineip" -p "port" -c "command"</p>
  
  <p>i can use the command as "base64 -d | tar -zvt" if i want to get the list inside my tar file.
  I have those objects;</p>
  
  <p>Sock.. is an object that implements the C socket.
  RCVBUFSIZE  = 2000 and the size i use to send and get data
  pid to know if i'm the child or the parent process</p>
  
  <p>To do that i i'm using the pipe and fork.
  the basic structure is:</p>
  
  <pre><code>int fd[2];
  pipe(fd);
  if((pid=fork()) == -1) exit(-1);
  if(pid == 0)
  {
   while((recvMsgSize = sock-&gt;recv(echoBuffer, RCVBUFSIZE)){
    write(fd[1], echoBuffer, recvMsgSize);
   }
  }
  else pipeback(fd,sock)
  </code></pre>
  
  <p>So i can get the data and send from the parent to the child.
  The client read from the stdin and send through the socket and the server read through the socket</p>
  
  <p>The problem is in the pipeBack</p>
  
  <pre><code>void pipeback(int *fdRef, TCPSocket *sock){
   char *buffer = new char[2000];
   int size;
   close(fdRef[1]);
   dup2(fdRef[0], 0);
   close(fdrEf[0]);
   pipe(fout)
   if((pid = fork()) == -1)exit(-1);
   if(pid ==0){
    close(fout[0]);
    dup2(fout[1], 1);
    close(fout[1]);
    execlp("bash", "bash", "-c", "base64", NULL);
   }
   else{
    close(fout[1]);
    while((size = read(fout[0], buffer, 2000)) &gt; 0){
     sock-&gt;send(buffer, size);
     write(fileno(stdout), buffer, size);
    }
   }
  }
  </code></pre>
  
  <p>the problem is the line "execlp("bash", "bash", "-c", "base64", NULL);" if i use the cat on the fourth argument it works, if i use one ls -lahtr is shows me the files on the folder, so, works like a charm.
  BUT, when i use base64 or uuencode... probably other commands it stops on the read line, and stops, dies, i used strace and the gdb to see what is happening.
  I don't know what i need to do to debug this process.
  So i created an separate program, only to read from the stdin and use the pipe to process on base64 or uuencode using the bash.
  It works, i thing it is something with the socket or the time, but i dont have any ideas.
  Sorry, but my English is not that gooood... XD.
  Thanks for everything</p>
  
  <p>NOTE:</p>
  
  <p>I used strace, and i noticed when i use the base64 the pid stops and then it tries to read from the pid (already stopped).</p>
  
  <p>Someone know how i can solve that?</p>