|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40221 Readline should re-read the window size
Submitted: 2007-01-24 16:41 UTC Modified: 2007-01-24 20:48 UTC
From: david at acz dot org Assigned:
Status: Not a bug Package: Readline related
PHP Version: 5.2.0 OS: SuSE Linux 9.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
41 + 25 = ?
Subscribe to this entry?

 [2007-01-24 16:41 UTC] david at acz dot org
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("first> ");
    $p = popen("less", "w");
    fwrite($p, "maximize window");
    readline("second> ");


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-24 17:50 UTC] david at acz dot org
I found a workaround:

    function xreadline($prompt)
        global $xreadline, $xreadline_line;
        $code = '$GLOBALS["xreadline"] = false;' .
                '$GLOBALS["xreadline_line"] = $line;' .
        $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)
        return is_null($xreadline_line) ? false : $xreadline_line;
 [2007-01-24 20:48 UTC]
Not PHP problem.
ext/readline is just a wrapper for libedit/GNU readline.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Jun 11 00:03:38 2023 UTC