Commit 304664212ea for php.net
commit 304664212ea526c8a6e98c367cf3db297df75095
Author: Weilin Du <weilindu@php.net>
Date: Wed Aug 12 18:13:36 2026 +0800
ext/readline: Fixed the interactive shell not waiting for the pager process to exit (#23047)
This backports 34a2949 to PHP 8.5
diff --git a/NEWS b/NEWS
index c3454aba1a7..c18dfda62aa 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 ca4e8eb4fe9..fb8f9a26163 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 00000000000..2d530947232
--- /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