-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: the fix for #8575 makes it impossible to intentionally close std handles #8827
Comments
This is about #8571, I assume. |
IMO, we should revert the fixes for now, so we can ship PHP 8.0.21RC1 and 8.1.8RC1 without the regression, and then reconsider how to best address #8575. |
I agree. #8571 is a regression and should be reverted. |
* PHP-8.0: Fix GH-8827: Intentionally closing std handles no longer possible
* PHP-8.1: Fix GH-8827: Intentionally closing std handles no longer possible
I have reverted the commits from PHP-8.0 and PHP-8.1; "master" will be addressed by #8833. |
The NEWS file from PHP 8.1.8 states:
This code does not appear to have been tested, as the commits made to Once again, I have replaced |
As I understand, the fix for now was intended to be just that– zero new code, backing out the patch that caused the issue, and going back to the code from the previous, working versions. Alas, I can indeed confirm that while the reversal in the PHP 8.0 branch appears to have been successful, in the PHP 8.1 branch it was not, and still includes the offending change. |
Yes, this revert was bad. Sorry! I'll give that another try ASAP. Feel free to open another bug report about this issue, since we can't re-use this ticket number. |
Description
On Unix-like systems, closing a std file handle has the useful property that the next file handle you open will inherit its place. This provides a very simple and effective way to reroute stdin/stdout/stderr during run time.
This has historically also been possible through PHP-CLI scripts, and as a result has become common practice, oft-repeated boilerplate code for using pcntl_fork() in particular, where it is almost always desirable for the forked children to stop using the parent's stdin/stdout/stderr.
This used to be as simple as, for example:
The fix for an unrelated issue in #8575, and unfortunately included in both PHP 8.1.7 and PHP 8.0.20, also makes it impossible for PHP code to willfully close the std file handles anymore. This breaks a whole swath of past code that depended on this functionality, a rather unwelcome and unexpected change for minor releases.
Here's a test:
With PHP 8.1.7 or 8.0.20 this now results in the following output instead:
3v4l link: https://3v4l.org/OgYWN
PHP Version
PHP 8.1.7
Operating System
Linux, macOS
The text was updated successfully, but these errors were encountered: