Let's say that we have a program X that continuously write a file for example the /tmp/test.file
I have a script in PHP that serves this file to the client so that he can download/read it.
How i'm able to do this continuously as the data are being written in the /tmp/test.file?
If i use the below code
<?php
$fp = fopen("/tmp/test.file","r");
while(!feof($fp))
{
echo fread($fp,4096);
}
fclose($fp);
It instantly stops because it reads the whole file until EOF so it doesnt care if another process is writing at this file.
Thank you