php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71229 Writing to "php://stdout" from the interactive shell makes it hang
Submitted: 2015-12-28 12:40 UTC Modified: 2017-10-24 05:20 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: michelezamuner at gmail dot com Assigned: laruence (profile)
Status: Assigned Package: *General Issues
PHP Version: 7.0.1 OS: Ubuntu 14.04.1 x86_64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-12-28 12:40 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-28 15:13 UTC] laruence@php.net
-Status: Open +Status: Verified
 [2015-12-28 15:13 UTC] 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 15:13 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2017-10-24 05:20 UTC] kalle@php.net
-Status: Verified +Status: Assigned
 [2021-06-18 03:41 UTC] mehwish dot yati at gmail dot com
With its auto two-sided printing, you can work efficiently. You may save your tones of time and paper with its 30-page auto document feeder. Its ink cartridges are durable and can be replaced by inexpensive individual ink cartridges. To achieve exact laser quality and bright colors, take this printer in your magnificent label and sticker printers' list.
You can find more guides here https://printerhow.com/best-printer-for-labels/
 [2021-12-12 22:54 UTC] kevinpatric at protonmail dot com
Get an error free printer <a href="https://printerdeets.com/">at printerdeets.com</a> and enjoy your printing process on the go.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC