#40221 [Opn->Bgs]: Readline should re-read the window size

From: Date: Wed, 24 Jan 2007 20:48:43 +0000
Subject: #40221 [Opn->Bgs]: Readline should re-read the window size
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-107997@lists.php.net to get a copy of this message
ID: 40221 Updated by: tony2001@php.net Reported By: david at acz dot org -Status: Open +Status: Bogus Bug Type: Readline related Operating System: SuSE Linux 9.3 PHP Version: 5.2.0 New Comment: Not PHP problem. ext/readline is just a wrapper for libedit/GNU readline. Previous Comments: ------------------------------------------------------------------------ [2007-01-24 17:50:07] david at acz dot org I found a workaround: <? function xreadline($prompt) { global $xreadline, $xreadline_line; $code = '$GLOBALS["xreadline"] = false;' . '$GLOBALS["xreadline_line"] = $line;' . 'readline_callback_handler_remove();'; $cb = create_function('$line', $code); readline_callback_handler_install($prompt, $cb); $signal = defined("SIGWINCH") ? SIGWINCH : 28; posix_kill(posix_getpid(), $signal); $xreadline = true; while ($xreadline) readline_callback_read_char(); return is_null($xreadline_line) ? false : $xreadline_line; } ?> ------------------------------------------------------------------------ [2007-01-24 16:41:27] david at acz dot org Description: ------------ The readline() function should re-read the window size every time it is called. The edit line and history get messed up if it doesn't get SIGWINCH (for example, if the window was resized in a child process). 1) Start the test program with a typical 80x40 window. 2) At the first prompt, press up to see that the history displays correctly. 3) Press enter to exit readline() and run less. 4) In less, maximize the terminal window, then quit less. 5) At the second prompt, press up and notice that the history is messed up. Reproduce code: --------------- <? $s = ""; for ($i = 65; $i <= 90; $i++) $s .= str_repeat(chr($i), 3) . " "; readline_add_history($s); readline("first> "); $p = popen("less", "w"); fwrite($p, "maximize window"); pclose($p); readline("second> "); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40221&edit=1

« previous php.bugs (#107997) next »