From f6c0c60ef63c1e528dd3bd945c8f22270bbe3837 Mon Sep 17 00:00:00 2001 From: nielsdos <7771979+nielsdos@users.noreply.github.com> Date: Sun, 30 Apr 2023 23:33:41 +0200 Subject: [PATCH] Fix GH-11104: STDIN/STDOUT/STDERR is not available for CLI without a script I found no reason why this is done this way. Of course this will allow users to do stupid stuff like `fclose(STDOUT);` etc. but if they type in that code they clearly know what they're doing... Close GH-11169. --- NEWS | 2 ++ sapi/cli/php_cli.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 268ae89ce7d..81095b5f96b 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ PHP NEWS - CLI: . Added pdeathsig to builtin server to terminate workers when the master process is killed. (ilutov) + . Fixed bug GH-11104 (STDIN/STDOUT/STDERR is not available for CLI without + a script). (nielsdos) - Core: . Fixed bug GH-9388 (Improve unset property and __get type incompatibility diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2f936a39b71..5e84ae7379c 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -951,9 +951,7 @@ do_repeat: PG(during_request_startup) = 0; switch (behavior) { case PHP_MODE_STANDARD: - if (script_file) { - cli_register_file_handles(); - } + cli_register_file_handles(); if (interactive) { EG(exit_status) = cli_shell_callbacks.cli_shell_run();