[php-src] PHP-8.5: ext/readline: Fixed the interactive shell not waiting for the pager process to exit (#23047)

From: Date: Wed, 12 Aug 2026 10:13:39 +0000
Subject: [php-src] PHP-8.5: ext/readline: Fixed the interactive shell not waiting for the pager process to exit (#23047)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140665@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Committer: GitHub (web-flow) Pusher: LamentXU123 Date: 2026-08-12T18:13:36+08:00 Commit: https://github.com/php/php-src/commit/304664212ea526c8a6e98c367cf3db297df75095 Raw diff: https://github.com/php/php-src/commit/304664212ea526c8a6e98c367cf3db297df75095.diff ext/readline: Fixed the interactive shell not waiting for the pager process to exit (#23047) This backports 34a2949 to PHP 8.5 Changed paths: A ext/readline/tests/readline_cli_pager.phpt M NEWS M ext/readline/readline_cli.c Diff: diff --git a/NEWS b/NEWS index c3454aba1a79..c18dfda62aa5 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.5.11 +- Readline: + . Fixed the interactive shell not waiting for the pager process to exit. + (Weilin Du) + 27 Aug 2026, PHP 8.5.10 diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index ca4e8eb4fe9f..fb8f9a261637 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -712,7 +712,7 @@ static int readline_shell_run(void) /* {{{ */ } if (pager_pipe) { - fclose(pager_pipe); + pclose(pager_pipe); pager_pipe = NULL; } diff --git a/ext/readline/tests/readline_cli_pager.phpt b/ext/readline/tests/readline_cli_pager.phpt new file mode 100644 index 000000000000..2d5309472324 --- /dev/null +++ b/ext/readline/tests/readline_cli_pager.phpt @@ -0,0 +1,29 @@ +--TEST-- +Interactive shell: output through cli.pager +--EXTENSIONS-- +readline +--SKIPIF-- +<?php +if (!function_exists('proc_open')) die('skip proc_open() not available'); +if (READLINE_LIB !== "readline") die('skip readline only'); +if (PHP_OS_FAMILY === 'Windows') die('skip tr pager is not portable on Windows'); +?> +--FILE-- +<?php +$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED'); +$ini = getenv('TEST_PHP_EXTRA_ARGS'); +$descriptorspec = [['pipe', 'r'], STDOUT, STDERR]; +$proc = proc_open("$php $ini -d cli.pager='tr a-z A-Z' -a", $descriptorspec, $pipes); +fwrite($pipes[0], "echo \"pager output\n\";\n"); +fwrite($pipes[0], "quit\n"); +fclose($pipes[0]); +proc_close($proc); +?> +--EXPECT-- +Interactive shell + +php > echo "pager output +php " "; +pager output +PAGER OUTPUT +php > quit

« previous php.cvs (#140665) next »