|  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
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
5 + 7 = ?
Subscribe to this entry?

 [2015-12-28 12:40 UTC] michelezamuner at gmail dot com
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-28 15:13 UTC]
-Status: Open +Status: Verified
 [2015-12-28 15:13 UTC]
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) {
-			if (strcmp(file_handle.filename, "-")) {
+			if (strcmp(file_handle.filename, "-") || interactive) {

however, I am trying to figure out a better solution
 [2015-12-28 15:13 UTC]
-Assigned To: +Assigned To: laruence
 [2017-10-24 05:20 UTC]
-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
 [2021-12-12 22:54 UTC] kevinpatric at protonmail dot com
Get an error free printer <a href="">at</a> and enjoy your printing process on the go.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 11:01:29 2024 UTC