--- Modules/readline.c.orig 2015-10-22 11:14:36.642818903 -0500 +++ Modules/readline.c 2015-10-22 11:14:48.259083388 -0500 @@ -940,6 +940,14 @@ #endif +static char sigwinch_received; + +static void +readline_sigwinch_handler(int sig) +{ + sigwinch_received = 1; +} + /* C function to call the Python completer. */ static char * @@ -1045,6 +1053,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 @@ -1130,6 +1140,11 @@ struct timeval *timeoutp = NULL; if (PyOS_InputHook) timeoutp = &timeout; + /* Update readline's view of the window size after SIGWINCH */ + if (sigwinch_received) { + rl_resize_terminal(); + sigwinch_received = 0; + } FD_SET(fileno(rl_instream), &selectset); /* select resets selectset if no input was available */ has_input = select(fileno(rl_instream) + 1, &selectset,