[php-src] Issue #8575: CLI closes standard streams too early

From: Date: Wed, 18 May 2022 15:30:45 +0000
Subject: [php-src] Issue #8575: CLI closes standard streams too early
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241533@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8575 Author: morrisonlevi ### Description This only affects extensions which might print to stderr (or stdout) after request shutdown, so prshutdown, mshutdown, and gshutdown, as well as the equivalent zend_extension shutdown. There's no need to close the file handles stin, stdout, and stderr nor their equivalent file descriptors (unless you dup them, then you need to close the dup). I hit this when trying to debug PHP lifecycle issues and nothing after request shutdown was showing up. In the case of one extension that was using a Rust library to print colored debug messages, it would panic because the library didn't expect stderr to actually get closed. Although the library should be more cautious, there's no need to close these streams. There are already two cases where we don't close these files: debug builds and if --repeat is used. I already have patches for this, expect to merge them shortly but wanted to have an issue number to use for the test. ### PHP Version Has been an issue at least as far back as PHP 5.4, still present on PHP 8.1. ### Operating System _No response_

« previous php.bugs (#241533) next »