From cc9d2bfa188ae0d9bc4ed593c86ffea877a65a39 Mon Sep 17 00:00:00 2001 From: Weilin Du Date: Wed, 5 Aug 2026 03:15:28 +0800 Subject: [PATCH] ext/readline: Fixed the interactive shell not waiting for the pager process to exit --- NEWS | 4 +++ ext/readline/readline_cli.c | 2 +- ext/readline/tests/readline_cli_pager.phpt | 29 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 ext/readline/tests/readline_cli_pager.phpt 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-- + +--FILE-- + +--EXPECT-- +Interactive shell + +php > echo "pager output +php " "; +pager output +PAGER OUTPUT +php > quit