Open
Description
Description
As of PHP8.3, the following code:
<?php
$descriptorspec = array();
$cwd = '/inaccessible/dir/';
$process = proc_open('/usr/bin/env php -r ""', $descriptorspec, $pipes, $cwd);
proc_close($process);
Resulted in this output:
PHP Warning: proc_open(): posix_spawn() failed: No such file or directory in /home/hans/test/test.php on line 4
PHP Fatal error: Uncaught TypeError: proc_close(): Argument #1 ($process) must be of type resource, false given in /home/hans/test/test.php:5
Stack trace:
#0 /home/hans/test/test.php(5): proc_close()
#1 {main}
thrown in /home/hans/test/test.php on line 5
But in PHP<8.3, it results in no output whatsoever, and proc_open succeeds.
This behavior change breaks real code in the wild: chrome-php/wrench#20
While I think the behavior change is good, I also think a E_DEPRECATED period is warranted, something like
Requesting an inaccessible working dir ($cwd) has been deprecated and will stop working in a future version of PHP
- Also for some unknown reason, when I test this locally, i get the posix_spawn() error, but when I test on Github CI, i don't get the posix_spawn() error (but proc_open() still fails.. silently.)
PHP Version
PHP8.3.0
Operating System
Ubuntu (both 22.04 and 24.04-beta)