Hello,
I need to read a result of the first script (that takes some time to
run) from the second script so that the first script doesn't block the
second. Here is a short example. do_smth_else() should be called
during test.php's sleep, instead the first fgets blocks the processing
of the parent script and do_smth_else is called only once. How can I
do a non-blocking fgets()? I use php 4.3.4 on windows xp
$process = popen("c:\php\php -f test.php", 'r');
stream_set_blocking($process, false);
do {
$line = fgets($process);
print $line;
do_smth_else();
if ($line === false) break;
} while(true);
pclose($process);
contents of the test.php:
<?php echo 'Hello';sleep(2); echo ' World!'; ?>