#20863 [Com]: md5_file() and exec() freeze

From: Date: Fri, 06 Dec 2002 17:41:52 +0000
Subject: #20863 [Com]: md5_file() and exec() freeze
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-26872@lists.php.net to get a copy of this message
ID: 20863 Comment by: mike.duncan@sonopress.com Reported By: mike.duncan@sonopress.com Status: Feedback Bug Type: Filesystem function related Operating System: SuSE 7.3 Pro PHP Version: 4CVS-2002-12-06 (stable) New Comment: I also tried adding ini_set("max_execution_time", "180") to the script and it changed nothing. Just to make sure it was not hitting this limit too. Previous Comments: ------------------------------------------------------------------------ [2002-12-06 11:38:07] mike.duncan@sonopress.com I do not have this enabled. My configure line looks like so: ./configure --enable-ftp --with-ldap=/usr/local/openldap --with-mysql=/usr --with-openssl=/usr/local/openssl I thought for the memory_limit directive to take effect would mean I would to have had to add --enable-momory-limit to the configuration. Has this changed recently (i.e. >= 4.2.1)? ------------------------------------------------------------------------ [2002-12-06 11:06:46] iliaa@php.net Does your PHP have a memory limit? ------------------------------------------------------------------------ [2002-12-06 10:44:55] mike.duncan@sonopress.com BTW, The files I am examining are all text. ------------------------------------------------------------------------ [2002-12-06 10:38:36] mike.duncan@sonopress.com Here is my src: -------------------- $files = array(); $dirs = array(); function getMD5OfFile($f) { return md5_file($f); //return exec("md5sum ".$f." | awk '{print $1}'"); } function getFiles($d) { global $files, $dirs; clearstatcache(); if($dir = @opendir($d)) { while(($file = @readdir($dir)) !== false) { if(($file != ".") && ($file != "..")) { if(is_dir($d."/".$file)) $dirs[] = $d."/".$file; elseif(is_file($d."/".$file) && (substr($file,0,1) != ".")) $files[] = $d."/".$file; } } } } /** Get files for directories **/ getFiles("/home/webdev"); while(($dir = array_shift($dirs)) !== null) { getFiles($dir); } /** Ouptut findings **/ while(($file = array_shift($files)) !== null) { echo $file.": ". getMD5FromFile($file) ."\n"; } ------------------ I first tried this with v4.2.1. What I am trying to do is get the MD5 for every file within the filesystem. Unfortunately this code freezes after about 20 or so files (md5_file() or exec() returns ok until then). If I uncomment the exec() return and comment the md5_file() return, the script hangs at exactly the same spot. If comment both out and run the script without md5'ing any files, I get a listing of all files (no problem). I have also tried replacing the md5_file() code with one that was listed here http://www.php.net/manual/en/function.md5-file.php that will read the file into a variable and do a md5() on that var. Unfortunately I got a FATAL: emalloc() error using that method. Finally, I tried getting the upgrading to v4.3.0-dev (latest snapshot from snaps) and got the same results. I cannot figure out why this hangs and does not bomb out. I think it has something to do with maybe a cache of some sort or the memory buffers are filling up. Maybe even something to with how I am traversing the array of directories? But then, why would it work without the md5 cals? I do not know, but I thought I would post it here and see what you guys think. TIA. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20863&edit=1

« previous php.bugs (#26872) next »