Bug #67552 [NEW]: proc_open is using a wrong initial working dir
| From: | iron at mail dot ua | Date: | Wed, 02 Jul 2014 08:47:46 +0000 |
| Subject: | Bug #67552 [NEW]: proc_open is using a wrong initial working dir | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186415@lists.php.net to get a copy of this message | ||
From: iron at mail dot ua
Operating system: FreeBSD
PHP version: 5.5.14
Package: Program Execution
Bug Type: Bug
Bug description:proc_open is using a wrong initial working dir
Description:
------------
I have the same issue under FreeBSD 10 with php-5.5.14 as #50524 but
only with proc_open(). Under Linux I got the expected result.
Test script:
---------------
<?php
chdir('/home/webadmin/test');
$fdSpecs = array(
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes);
echo 'Without $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);
echo PHP_EOL;
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes,
NULL);
echo 'With NULL as $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);
echo PHP_EOL;
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes,
getcwd());
echo 'With getcwd() as $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);
echo PHP_EOL;
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes,
'/');
echo 'With "/" as $cwd argument:', PHP_EOL;
echo stream_get_contents($pipes[1]);
echo PHP_EOL;
echo 'Exec $CWD: ', PHP_EOL;
echo exec('php -r "var_dump(getcwd());"'), PHP_EOL;
?>
Expected result:
----------------
Without $cwd argument:
string(14) "/home/webadmin/test"
With NULL as $cwd argument:
string(14) "/home/webadmin/test"
With getcwd() as $cwd argument:
string(19) "/home/webadmin/test"
With "/" as $cwd argument:
string(1) "/"
Exec $CWD:
string(19) "/home/webadmin/test"
Actual result:
--------------
Without $cwd argument:
string(14) "/home/webadmin"
With NULL as $cwd argument:
string(14) "/home/webadmin"
With getcwd() as $cwd argument:
string(19) "/home/webadmin/test"
With "/" as $cwd argument:
string(1) "/"
Exec $CWD:
string(19) "/home/webadmin/test"
--
Edit bug report at https://bugs.php.net/bug.php?id=67552&edit=1
--