ID: 50524 Updated by: [email protected] Reported By: carsten_sttgt at gmx dot de -Status: Bogus +Status: Feedback Bug Type: Program Execution Operating System: win32 only PHP Version: 5.3.1
Previous Comments: ------------------------------------------------------------------------ [2009-12-23 13:56:25] [email protected] This is expected, as also noted in the manual on the proc_open() page for the $cwd parameter. If NULL is supplied to $cwd, then on Windows atleast the directory where the PHP script interpreter is located is the cwd. ------------------------------------------------------------------------ [2009-12-18 19:33:35] carsten_sttgt at gmx dot de Description: ------------ Hello, each program execution function: - exec() - passthru() - shell_exec() - system() - backtick operator or popen() is using the current script (working) directory as working directory for the command which is executed. Only proc_open() is using a different directory: - for apache2handler it the Apache ServerRoot - for CGI it's the php-cgi.exe directory - for FastCGI (mod_fgcid) it's also the php-cgi.exe directory On *nix (mod_fcgid) the proc_open() working directory is as expected also the script (working) directory. Regards, Carsten Reproduce code: --------------- <?php header('Content-Type: text/plain'); echo "------getcwd()---------\n"; echo getcwd()."\n\n"; echo "\n\n-------popen()---------\n"; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $cmd = 'dir'; } else { $cmd = 'ls'; } $process = popen($cmd, 'r'); while (!feof($process)) { echo fread($process, 80); } pclose($process); echo "\n\n-------passthru()------\n"; passthru($cmd); echo "\n\n------proc_open()------\n"; $descriptorspec = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w') ); $process = proc_open($cmd, $descriptorspec, $pipes); while (!feof($pipes[1])) { echo fread($pipes[1], 80); } fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process); ?> Expected result: ---------------- getcwd: C:\Apache2.2\htdocs 3 times a directory listing of: C:\Apache2.2\htdocs Actual result: -------------- getcwd: C:\Apache2.2\htdocs 2 times (popen, passthru) a directory listing of: C:\Apache2.2\htdocs 1 time (proc_open) a directory listing of: apache2handler: C:\Apache2.2 or CGI/FastCGI: C:\PHP ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50524&edit=1
