]> granicus.if.org Git - procps-ng/commitdiff
top: offer define to allow/suppress excessive SIGWINCH
authorJim Warner <james.warner@comcast.net>
Wed, 16 Jan 2013 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Thu, 24 Jan 2013 10:29:24 +0000 (21:29 +1100)
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>
top/top.c
top/top.h

index ea3d9e0c410f4dd8974f472621f90174aebf191a..a1fad9fca38b6faf213bc5a2093d4400d2daf033 100644 (file)
--- 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
 \f
 /*######  Interactive Input support (do_key helpers)  ####################*/
index f2dcaf105161366d5a12434bb6a6d33a77f350de..c19808c199a075cb60441d766105c22a668feeef 100644 (file)
--- 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)  */