title: popen() alternative
body: <p>My question is extension of this one: <a href="https://stackoverflow.com/questions/6742635/popen-creates-an-extra-sh-process">popen creates an extra sh process</a></p>
  
  <p>Motives:</p>
  
  <p>1) My program need to create a child which does <code>tail</code> on a file. I need to process the output line by line. That is why I am using <code>popen</code> because it returns FILE *. I can easily fetch single line, do what I need to do and print it. </p>
  
  <p>One problem with popen is that you do not get pid of child (tail command in my case). </p>
  
  <p>2) My program should not exit before its child is done. So I need to do <code>wait</code>; but without pid, I cannot do it.</p>
  
  <p>How can I achieve both the goals? </p>
  
  <p>A possible (kludge) solution: do execvp("tail -f file > tmpfile") and the keep reading that tmpfile. I am not sure how good this solution is, though.</p>