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

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=71229&edit=1

 ID:                 71229
 Updated by:         [email protected]
 Reported by:        michelezamuner at gmail dot com
 Summary:            Writing to "php://stdout" from the interactive shell
                     makes it hang
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            *General Issues
 Operating System:   Ubuntu 14.04.1 x86_64
 PHP Version:        7.0.1
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.