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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michelezamuner at gmail dot com
New email:
PHP Version: OS:

 

 [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/
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 25 19:03:39 2021 UTC