--- python3.4-3.4.2/Modules/readline.c.orig 2014-10-08 03:18:15.000000000 -0500 +++ python3.4-3.4.2/Modules/readline.c 2016-03-22 21:51:10.523371535 -0500 @@ -899,6 +899,17 @@ #endif +static volatile sig_atomic_t sigwinch_received; +static sighandler_t sigwinch_ohandler; + +static void +readline_sigwinch_handler(int signum) +{ + sigwinch_received = 1; + if (sigwinch_ohandler && sigwinch_ohandler != SIG_IGN && sigwinch_ohandler != SIG_DFL) + sigwinch_ohandler(signum); +} + /* C function to call the Python completer. */ static char * @@ -1004,6 +1015,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 */ + sigwinch_ohandler = PyOS_setsig(SIGWINCH, readline_sigwinch_handler); /* Set our hook functions */ rl_startup_hook = on_startup_hook; #ifdef HAVE_RL_PRE_INPUT_HOOK @@ -1091,6 +1104,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,