diff -r 10b965d59b49 Modules/readline.c --- a/Modules/readline.c Thu Oct 22 20:19:14 2015 +0300 +++ b/Modules/readline.c Thu Oct 22 22:23:32 2015 -0500 @@ -941,6 +941,14 @@ #endif +static volatile sig_atomic_t sigwinch_received; + +static void +readline_sigwinch_handler(int signum) +{ + sigwinch_received = 1; +} + /* C function to call the Python completer. */ static char * @@ -1046,6 +1054,8 @@ /* Bind both ESC-TAB and ESC-ESC to the completion function */ rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap); rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap); + /* Set up signal handler for window resize */ + PyOS_setsig(SIGWINCH, readline_sigwinch_handler); /* Set our hook functions */ rl_startup_hook = on_startup_hook; #ifdef HAVE_RL_PRE_INPUT_HOOK @@ -1131,6 +1141,11 @@ struct timeval *timeoutp = NULL; if (PyOS_InputHook) timeoutp = &timeout; + /* Update readline's view of the window size after SIGWINCH */ + if (sigwinch_received) { + sigwinch_received = 0; + rl_resize_terminal(); + } FD_SET(fileno(rl_instream), &selectset); /* select resets selectset if no input was available */ has_input = select(fileno(rl_instream) + 1, &selectset,