From: jtnix at maine dot rr dot com
Operating system: Linux 2.4
PHP version: 4.3.7
PHP Bug Type: Program Execution
Bug description: pclose() and proc_close() not returning proper exit status
Description:
------------
version 4.3.7 proc_close() and pclose() are not returning proper exit
status codes from spawned processes.
Reproduce code:
---------------
$cmd = "rsync /pinky /brain";
## proc_ method
$setup = array( 1 => array("pipe", "w"));
$process = proc_open($cmd, $setup, $pipes);
if (is_resource($process)) {
while(!feof($pipes[1])) {
echo fgets($pipes[1], 1024);
}
fclose($pipes[1]);
$rv = proc_close($process);
echo ":: proc_close() method ::\n";
echo "exit val: $rv\n\n";
}
## popen() method
$phnd = popen("$cmd", 'r');
while (!feof($phnd)) {
$in = fread($phnd, 2048);
echo $read;
}
$rv = pclose($phnd);
echo ":: pclose() ::\n";
echo "exit val: $rv\n\n";
Expected result:
----------------
## PHP 4.3.3 ##
link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: proc_close() method ::
exit val: 23
link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: pclose() ::
exit val: 23
Actual result:
--------------
## PHP 4.3.7 ##
link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: proc_close() method ::
exit val: -1
link_stat /pinky : No such file or directory
rsync error: some files could not be transferred (code 23) at main.c(620)
:: pclose() ::
exit val: -1
--
Edit bug report at http://bugs.php.net/?id=29123&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29123&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29123&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29123&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29123&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29123&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29123&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29123&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29123&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29123&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29123&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29123&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29123&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29123&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29123&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29123&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29123&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29123&r=float