title: parent process not reading the data from named pipe completely
body: <p>I am trying to fork a process and execute a command. i am creating a named pipe and trying to execute the command from the child process which writes the STDOUT to pipe. parent process will read from the pipe. my problem is that the parent process is not reading the data from the pipe completely. here is the code.</p>
  
  <pre><code>fifo_fd = mkfifo(MY_FIFO, 0666);
  FILE *fp = fdopen(fifo_fd, "r");
  childpid = fork();
  if (childpid == 0)
  {
     dup2(fifo_fd, STDOUT_FILENO);
     dup2(fifo_fd, STDERR_FILENO);
     close(fifo_fd);
     execv(arg_list[0], arg_list);
     _exit (127);
  }
  else
  {
     //parent process
     if(waitpid(childpid, &amp;status,WNOHANG ) == -1) {
       // now we kill the child and return failure.
     }
  
     fcntl(fd, F_SETFL, O_NONBLOCK);
  
     while((fgets(buf, sizeof(buf)-1,fp))) {
     strcat(result,buf); //we copy the buf to result
  }
  return success;
  }
  </code></pre>