forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite168dfe
committed
Cope with Readline's failure to track SIGWINCH events outside of input.
It emerges that libreadline doesn't notice terminal window size changeevents unless they occur while collecting input. This is easy to stumbleover if you resize the window while using a pager to look at query output,but it can be demonstrated without any pager involvement. The symptom isthat queries exceeding one line are misdisplayed during subsequent inputcycles, because libreadline has the wrong idea of the screen dimensions.The safest, simplest way to fix this is to call rl_reset_screen_size()just before calling readline(). That causes an extra ioctl(TIOCGWINSZ)for every command; but since it only happens when reading from a tty, theperformance impact should be negligible. A more valid objection is thatthis still leaves a tiny window during entry to readline() wherein deliveryof SIGWINCH will be missed; but the practical consequences of that areprobably negligible. In any case, there doesn't seem to be any good way toavoid the race, since readline exposes no functions that seem safe to callfrom a generic signal handler --- rl_reset_screen_size() certainly isn't.It turns out that we also need an explicit rl_initialize() call, elserl_reset_screen_size() dumps core when called before the first readline()call.rl_reset_screen_size() is not present in old versions of libreadline,so we need a configure test for that. (rl_initialize() is present atleast back to readline 4.0, so we won't bother with a test for it.)We would need a configure test anyway since libedit's emulation oflibreadline doesn't currently include such a function. Fortunately,libedit seems not to have any corresponding bug.Merlin Moncure, adjusted a bit by me1 parentb9a46f8 commite168dfe
File tree
4 files changed
+17
-2
lines changed- src
- bin/psql
- include
4 files changed
+17
-2
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12415 | 12415 |
| |
12416 | 12416 |
| |
12417 | 12417 |
| |
12418 |
| - | |
| 12418 | + | |
12419 | 12419 |
| |
12420 | 12420 |
| |
12421 | 12421 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1545 | 1545 |
| |
1546 | 1546 |
| |
1547 | 1547 |
| |
1548 |
| - | |
| 1548 | + | |
1549 | 1549 |
| |
1550 | 1550 |
| |
1551 | 1551 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
68 | 79 |
| |
69 | 80 |
| |
70 | 81 |
| |
| |||
330 | 341 |
| |
331 | 342 |
| |
332 | 343 |
| |
| 344 | + | |
333 | 345 |
| |
334 | 346 |
| |
335 | 347 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
406 | 406 |
| |
407 | 407 |
| |
408 | 408 |
| |
| 409 | + | |
| 410 | + | |
| 411 | + | |
409 | 412 |
| |
410 | 413 |
| |
411 | 414 |
| |
|
0 commit comments
Comments
(0)