related to this question
my script basically runs fine but sometimes it stop responding at the fread function call and I can't seem to find the reason of the failure.
private function run_lengthy_job($command, $message) {
for($handle = popen($command, 'r'); !feof($handle); sleep(2)) {
printf("[%s]\t%s\n", time(), $message);
// log the operation
exec(sprintf('logger "%s"',
escapeshellarg(fread($handle, 1024))));
}
pclose($handle);
}
example command
hg clone -v --debug http://some.repository.com/hgwebdir.cgi/some_repo some_repo
for now it is failing while cloning a large repository. the same problem persists even if I change fread to fgets.
Brief information about my php environment,
PHP 5.2.4-2ubuntu5.6 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 17 2009 14:29:38)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans
Running on ubuntu 8.04.2
EDIT: tried proc_open instead of popen and the script stuck at the same place. EDIT: replaced fread with stream_get_contents, but still stuck at the same place...