Fix a regression introduced with commit 20c3f14cc: If we can read from a process'

pipe doesn't mean the exit code of the process in question is zero, this is
actually what pclose() returns.
This commit is contained in:
Thomas Keller 2011-06-11 00:44:32 +02:00
parent 118ca9f11f
commit 2f30e4e2f6

View File

@ -101,16 +101,15 @@ class IDF_Scm
*/ */
public static function exec($caller, $cmd, &$out=null, &$return=null) public static function exec($caller, $cmd, &$out=null, &$return=null)
{ {
$return = 1; $return = -1;
Pluf_Log::stime('timer'); Pluf_Log::stime('timer');
$fp = popen($cmd, 'r'); $fp = popen($cmd, 'r');
$buf = ''; $buf = '';
if ($fp !== false) { if ($fp !== false) {
$return = 0;
while (!feof($fp)) { while (!feof($fp)) {
$buf .= fread($fp, 1024); $buf .= fread($fp, 1024);
} }
pclose($fp); $return = pclose($fp);
} }
$out = preg_split('/\r\n|\r|\n/', $buf); $out = preg_split('/\r\n|\r|\n/', $buf);
$elem = count($out); $elem = count($out);