title: PHP - Blocking File Read
body: <p>I have a file that is getting added to remotely (file.txt). From SSH, I can call <code>tail -f file.txt</code> which will display the updated contents of the file. I'd like to be able to do a blocking call to this file that will return the last appended line. A pooling loop simply isn't an option. Here's what I'd like:</p>
  
  <pre><code>$cmd = "tail -f file.txt";
  $str = exec($cmd);
  </code></pre>
  
  <p>The problem with this code is that <code>tail</code> will never return. Is there any kind of wrapper function for tail that will kill it when once it has returned content? Is there a better way to do this in a low overhead way?</p>