From 3e5016c2898d7129d2cdae7b1def8fe85d41619f Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 18 Sep 2022 00:00:00 -0500 Subject: [PATCH] top: avoid any potential race involving 'BREAK_screen' 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 3ea1bc779fb7ca5bf065a5ca620ec5b5823bc61c . May, 2022 - maybe force the bottom window off commit d66c1f39b52d53ec279fc638aa4a6352d7672201 Signed-off-by: Jim Warner --- src/top/top.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/top/top.c b/src/top/top.c index 9b2720ec..718dbb39 100644 --- a/src/top/top.c +++ b/src/top/top.c @@ -2464,6 +2464,7 @@ static void fields_utility (void) { spewFI signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -3285,6 +3286,7 @@ static int insp_view_choice (struct pids_stack *p) { int key, curlin = 0, curcol = 0; signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -3407,6 +3409,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(); @@ -4586,6 +4589,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(); @@ -5335,6 +5339,7 @@ static void help_view (void) { putp((Cursor_state = Cap_curs_huge)); signify_that: + Frames_signal = BREAK_off; putp(Cap_clr_scr); adj_geometry(); @@ -5353,22 +5358,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;