Bug #71229 [Ver->Asn]: Writing to "php://stdout" from the interactive shell makes it hang

From: Date: Tue, 24 Oct 2017 05:20:20 +0000
Subject: Bug #71229 [Ver->Asn]: Writing to "php://stdout" from the interactive shell makes it hang
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211931@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71229&edit=1 ID: 71229 Updated by: kalle@php.net Reported by: michelezamuner at gmail dot com Summary: Writing to "php://stdout" from the interactive shell makes it hang -Status: Verified +Status: Assigned Type: Bug Package: *General Issues Operating System: Ubuntu 14.04.1 x86_64 PHP Version: 7.0.1 Assigned To: laruence Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2015-12-28 15:13:16] laruence@php.net An quick fix could be : diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index b4288b8..c2413fa 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -964,7 +964,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ PG(during_request_startup) = 0; switch (behavior) { case PHP_MODE_STANDARD: - if (strcmp(file_handle.filename, "-")) { + if (strcmp(file_handle.filename, "-") || interactive) { cli_register_file_handles(); } however, I am trying to figure out a better solution ------------------------------------------------------------------------ [2015-12-28 12:40:42] michelezamuner at gmail dot com Description: ------------ In the interactive shell, after executing a function that writes a string to "php://stdout" file, the prompt doesn't appear back, and no input from the keyboard is recognized. The only thing left to do is terminating the process (Ctrl+C) and starting the shell again. Test script: --------------- // Start the interactive shell // $ php -a file_put_contents("php://stdout", "Hello, World!"); // The string is correctly printed, but no prompt is available any more, // and no keyboard input is recognized. Expected result: ---------------- After printing the expected string (which happens correctly) I expect the prompt "php > " to be available again, and to be able to continue working with the shell. Actual result: -------------- The prompt "php > " doesn't appear after printing the string, and the shell is frozen, not accepting any input from the keyboard. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71229&edit=1

« previous php.bugs (#211931) next »