[php-src] Issue #9551: File descriptors / some procfs entries not openable by php
| From: | SpencerMalone | Date: | Fri, 16 Sep 2022 03:18:42 +0000 |
| Subject: | [php-src] Issue #9551: File descriptors / some procfs entries not openable by php | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242425@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9551
Author: SpencerMalone
### Description
The following code:
```php
<?php
file_put_contents("/proc/1/fd/1", "hi");
```
Resulted in this output:
```
file_put_contents(/proc/1/fd/1): failed to open stream: No such file or directory
```
But I expected this output instead:
```
2
```
This is highly impactful for containerized PHP environments.
php-fpm has unique
workarounds that they've utilized, and in the past the fd stream wrapper was
implemented to support managing the current process's file descriptors, but if you are in a
different SAPI and/or utilize forking or execing to other PHP scripts, stdout in a
docker container quickly turns into a black hole in terms of container logging, where it's
expected that all logs are sent to the PID 1 stdout/err.
### PHP Version
7.4
### Operating System
Centos 7.9