From e81b58beaabfdbf93c5231642ec1205a9dfc1f3c Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 19 Sep 2022 00:00:00 -0500 Subject: top: avoid any potential race involving 'BREAK_screen' <=== port of newlib 3e5016c2 ______________________________ original newlib message ----------------------------------- ( minus git hash ) When that 'Bottom' window was being finalized, an enum of BREAK_screen was added to the Frames_signal values. This was done so some full screen replacement function could flag the need for that bottom window to go away. Around that same time, top was made more responsive to keyboard input so that residual portions of a previous bottom window would not linger until the next refresh. This happened if going from a larger (^N, environment) bottom window to some smaller window (^P, namespaces). The combined effect of these changes was to create the potential race condition this commit addresses. If the user encountered a SIGWINCH while on any of those full screen replacement displays (help, fields mgmt, etc.), endless redraws would occur. A ^C was the only option. Henceforth we will protect against any redraw loops by clearing Frames_signal each time a redraw is required. [ along the way, we'll make the 'q' key work on that ] t secondary 'windows' help screen as it should, even ] [ though it is not documented on that screen itself. ] Reference(s): . May, 2022 - more responsive to keyboard input commit ........................................ . May, 2022 - maybe force the bottom window off commit ........................................ Signed-off-by: Jim Warner --- top/top.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/top/top.c b/top/top.c index 9c046e5..2e8e58c 100644 --- a/top/top.c +++ b/top/top.c @@ -2506,6 +2506,7 @@ static void fields_utility (void) { spewFI signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -3556,6 +3557,7 @@ static int insp_view_choice (proc_t *p) { int key, curlin = 0, curcol = 0; signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -3678,6 +3680,7 @@ static void inspection_utility (int pid) { // must re-hide cursor since the prompt for a pid made it huge putp((Cursor_state = Cap_curs_hide)); signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -4778,6 +4781,7 @@ static void wins_colors (void) { wins_clrhlp(w, 1); putp((Cursor_state = Cap_curs_huge)); signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -5504,6 +5508,7 @@ static void help_view (void) { putp((Cursor_state = Cap_curs_huge)); signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -5522,22 +5527,26 @@ signify_that: if (key < 1) goto signify_that; switch (key) { + // these keys serve the primary help screen case kbd_ESC: case 'q': break; case '?': case 'h': case 'H': do { - putp(Cap_home); +signify_this: + Frames_signal = BREAK_off; + putp(Cap_clr_scr); + adj_geometry(); show_special(1, fmtmk(N_unq(WINDOWS_help_fmt) , w->grpname , Winstk[0].rc.winname, Winstk[1].rc.winname , Winstk[2].rc.winname, Winstk[3].rc.winname)); putp(Cap_clr_eos); fflush(stdout); - if (Frames_signal || (key = iokey(IOKEY_ONCE)) < 1) { - adj_geometry(); - putp(Cap_clr_scr); - } else w = win_select(key); - } while (key != kbd_ENTER && key != kbd_ESC); + if (Frames_signal || (key = iokey(IOKEY_ONCE)) < 1) + goto signify_this; + else w = win_select(key); + // these keys serve the secondary help screen + } while (key != kbd_ENTER && key != kbd_ESC && key != 'q'); break; default: goto signify_that; -- cgit v1.2.1