From 4f33b6b8c56464b4044deb29a3bb0e32622e108f Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 16 Jan 2013 00:00:00 -0600 Subject: [PATCH] top: offer define to allow/suppress excessive SIGWINCH After carefully working our way to the point where the excessive SIGWINCH interrupts are now throttled, along comes a commit which reverses all those prior efforts. Actually it doesn't. It simply allows one to choose if all those efforts should be reversed or remain active. Why in the world would you even want to consider that? Quite simply, to opt for responsiveness over overhead. Oh, and depending on the terminal emulator used for X, by enabling this OFF_SIGWINCH #define you will be able to avoid the need for an extra keystroke after resize. Besides it was an interesting programming challenge to see just how few lines of code would be needed to make it possible. Bottom line? Only 1 source line required! (actually 0 lines, since the define disables one line) (everything is perfectly justified plus right margins) (are completely filled, but of course it must be luck) Reference(s): http://www.freelists.org/post/procps/unwanted-topinspect-window-enclosure-with-the-terminal-size-change Signed-off-by: Jim Warner --- top/top.c | 6 ++++++ top/top.h | 1 + 2 files changed, 7 insertions(+) diff --git a/top/top.c b/top/top.c index ea3d9e0c..a1fad9fc 100644 --- a/top/top.c +++ b/top/top.c @@ -884,7 +884,11 @@ static inline int ioa (struct timespec *ts) { FD_ZERO(&fs); FD_SET(STDIN_FILENO, &fs); +#ifdef OFF_SIGWINCH // conditional comments are silly, but help in documenting + // hold here until we've got keyboard input, any signal (including SIGWINCH) +#else // hold here until we've got keyboard input, any signal except SIGWINCH +#endif // or (optionally) we timeout with nanosecond granularity rc = pselect(STDIN_FILENO + 1, &fs, NULL, NULL, ts, &Sigwinch_set); @@ -3741,7 +3745,9 @@ static void wins_stage_2 (void) { // lastly, initialize a signal set used to throttle one troublesome signal sigemptyset(&Sigwinch_set); +#ifndef OFF_SIGWINCH sigaddset(&Sigwinch_set, SIGWINCH); +#endif } // end: wins_stage_2 /*###### Interactive Input support (do_key helpers) ####################*/ diff --git a/top/top.h b/top/top.h index f2dcaf10..c19808c1 100644 --- a/top/top.h +++ b/top/top.h @@ -39,6 +39,7 @@ //#define NOBOOST_MEMS /* disable extra precision for mem fields */ //#define NOBOOST_PCNT /* disable extra precision for % fields */ //#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */ +//#define OFF_SIGWINCH /* favor response over reduced signal load */ //#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */ //#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */ //#define PRETEND4CPUS /* pretend we're smp with 4 ticsers (sic) */