|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41904 proc_open with empty array as $env should pass empty environment to process
Submitted: 2007-07-05 13:35 UTC Modified: 2007-08-19 16:10 UTC
From: martin dot partel at mbnet dot fi Assigned:
Status: Closed Package: Program Execution
PHP Version: 5.2.3 OS: Linux
Private report: No CVE-ID:
 [2007-07-05 13:35 UTC] martin dot partel at mbnet dot fi
The documentation of proc_open states that passing NULL as the $env 
parameter of proc_open has the child process use the same 
environment as the current PHP process. Passing an empty array seems 
to have the same effect, even though intuitively it should give the 
child process an empty environment.

Reproduce code:
echo '<pre>';
$descriptorspec = array(
   0 => array("pipe", "r"),
   1 => array("pipe", "w"),
$cwd = '/tmp';
$env = array();
$process = proc_open('php', $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
    fwrite($pipes[0], '<?php print_r($_ENV); ?>');

    echo stream_get_contents($pipes[1]);


Expected result:
The script should output an (almost) empty $_ENV.

Actual result:
The script outputs the $_ENV of the parent process.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-05 13:51 UTC]
Reclassified as docu issue.
 [2007-08-16 12:48 UTC]
Empty array should pass empty environment to be able to pass this special value.
 [2007-08-17 10:43 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Now empty env array passes empty environment like it should.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 05:01:34 2015 UTC