proc_open inaccessible cwd behavior change in 8.3
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
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: https://github.com/chrome-php/wrench/pull/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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied proc_open() and proc_close() reproduction on Ubuntu with PHP 8.3, using the inaccessible cwd and comparing local and GitHub CI results. Trace the proc_open() behavior around the posix_spawn() failure, then define the expected deprecation or failure behavior and add coverage for the differing outcomes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100