Bug #67552 [Opn->Fbk]: proc_open is using a wrong initial working dir
| From: | cmb@php.net | Date: | Tue, 06 Apr 2021 11:30:29 +0000 |
| Subject: | Bug #67552 [Opn->Fbk]: proc_open is using a wrong initial working dir | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233213@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67552&edit=1
ID: 67552
Updated by: cmb@php.net
Reported by: iron at mail dot ua
Summary: proc_open is using a wrong initial working dir
-Status: Open
+Status: Feedback
Type: Bug
Package: Program Execution
Operating System: FreeBSD
PHP Version: 5.5.14
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Did you use a thread-safe (ZTS) PHP build? In this case the
behavior is expected since the CWD is virtual and not really set
for the OS.
Previous Comments:
------------------------------------------------------------------------
[2014-07-02 08:47:45] iron at mail dot ua
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 this bug report at https://bugs.php.net/bug.php?id=67552&edit=1