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 <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2013-01-16 00:00:00 -06:00 committed by Craig Small
parent dd357e70e7
commit 4f33b6b8c5
2 changed files with 7 additions and 0 deletions

View File

@ -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) ####################*/

View File

@ -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) */