Re: fix for readline terminal size problems when window is resized with open pager - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: fix for readline terminal size problems when window is resized with open pager
Date
Msg-id CAHyXU0xRJPtisgwf51EXwt=kGs3U21+scm-HXwsSzLgT0QQmYg@mail.gmail.com
Whole thread Raw
In response to Re: fix for readline terminal size problems when window is resized with open pager  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: fix for readline terminal size problems when window is resized with open pager
List pgsql-hackers
On Wed, Dec 16, 2015 at 1:29 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I did some more experimentation and concluded that actually, this problem
> has nothing whatsoever to do with pager invocations.  What seems to really
> be happening is that libreadline activates its SIGWINCH handler only while
> it's being called to collect input, which is fine in itself, but *it does
> not notice screen resizes that happen when the handler is not active*.
>
> You can prove this by doing, say, "select pg_sleep(10);" and resizing
> the window before the backend comes back.  Readline never notices the
> resize, even though no pager invocation happens at all.
>
> So I now think that print.c shouldn't be involved at all, and the right
> thing to do is just have gets_interactive() invoke the resize function
> immediately before calling readline().  That will still leave a window
> for SIGWINCH to be missed, but it's a pretty tiny one.

right -- agreed.

> And somebody oughta report this as a libreadline bug ...

See https://bugs.python.org/issue23735 for background.  Apparently
this is expected behavior (and we are far from the only ones
complaining about it):

"And so we reach where we are. If a SIGWINCH arrives while readline is
not active, and the application using callback mode does not catch it and
tell readline about the updated screen dimensions (rl_set_screen_size()
exists for this purpose), readline will not know about the new size."

merlin



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: fix for readline terminal size problems when window is resized with open pager
Next
From: Tomas Vondra
Date:
Subject: Re: On-demand running query plans using auto_explain and signals