Blame SOURCES/0001-top-refine-some-miscellaneous-signals-interrupt-stuf.patch

2006ba
From e5d1a884f4e780aca7f9eaf68a51b967f9b43abf Mon Sep 17 00:00:00 2001
2006ba
From: Jim Warner <james.warner@comcast.net>
2006ba
Date: Sun, 30 Jun 2013 00:00:00 -0500
2006ba
Subject: [PATCH 1/2] top: refine some miscellaneous signals interrupt stuff
2006ba
2006ba
This commit mostly justs renames a few identifiers but
2006ba
it also will now suppress any end-of-job report if top
2006ba
wasn't ended via the 'q' key convention (i.e. signal).
2006ba
2006ba
Signed-off-by: Jim Warner <james.warner@comcast.net>
2006ba
---
2006ba
 top/top.c | 48 +++++++++++++++++++++++++-----------------------
2006ba
 top/top.h |  4 ++--
2006ba
 2 files changed, 27 insertions(+), 25 deletions(-)
2006ba
2006ba
diff --git a/top/top.c b/top/top.c
2006ba
index cdcf3c0..c1c61dd 100644
2006ba
--- a/top/top.c
2006ba
+++ b/top/top.c
2006ba
@@ -174,7 +174,7 @@ static WIN_t *Curwin;
2006ba
            and/or that are simply more efficiently handled as globals
2006ba
            [ 'Frames_...' (plural) stuff persists beyond 1 frame ]
2006ba
            [ or are used in response to async signals received ! ] */
2006ba
-static volatile int Frames_resize;     // time to rebuild all column headers
2006ba
+static volatile int Frames_signal;     // time to rebuild all column headers
2006ba
 static          int Frames_libflags;   // PROC_FILLxxx flags
2006ba
 static int          Frame_maxtask;     // last known number of active tasks
2006ba
                                        // ie. current 'size' of proc table
2006ba
@@ -377,7 +377,7 @@ static void bye_bye (const char *str) {
2006ba
    at_eoj();                 // restore tty in preparation for exit
2006ba
 #ifdef ATEOJ_RPTSTD
2006ba
 {  proc_t *p;
2006ba
-   if (!str && Ttychanged) { fprintf(stderr,
2006ba
+   if (!str && !Frames_signal && Ttychanged) { fprintf(stderr,
2006ba
       "\n%s's Summary report:"
2006ba
       "\n\tProgram"
2006ba
       "\n\t   Linux version = %u.%u.%u, %s"
2006ba
@@ -447,7 +447,7 @@ static void bye_bye (const char *str) {
2006ba
 
2006ba
 #ifndef OFF_HST_HASH
2006ba
 #ifdef ATEOJ_RPTHSH
2006ba
-   if (!str && Ttychanged) {
2006ba
+   if (!str && !Frames_signal && Ttychanged) {
2006ba
       int i, j, pop, total_occupied, maxdepth, maxdepth_sav, numdepth
2006ba
          , cross_foot, sz = HHASH_SIZ * (unsigned)sizeof(int);
2006ba
       int depths[HHASH_SIZ];
2006ba
@@ -588,6 +588,7 @@ static void sig_endpgm (int dont_care_sig) {
2006ba
 // POSIX.1-2004 async-signal-safe: sigfillset, sigprocmask
2006ba
    sigfillset(&ss);
2006ba
    sigprocmask(SIG_BLOCK, &ss, NULL);
2006ba
+   Frames_signal = BREAK_sig;
2006ba
    bye_bye(NULL);
2006ba
    (void)dont_care_sig;
2006ba
 } // end: sig_endpgm
2006ba
@@ -619,7 +620,7 @@ static void sig_paused (int dont_care_sig) {
2006ba
 #endif
2006ba
    if (keypad_xmit) putp(keypad_xmit);
2006ba
    putp(Cursor_state);
2006ba
-   Frames_resize = RESIZ_sig;
2006ba
+   Frames_signal = BREAK_sig;
2006ba
    (void)dont_care_sig;
2006ba
 } // end: sig_paused
2006ba
 
2006ba
@@ -630,7 +631,7 @@ static void sig_paused (int dont_care_sig) {
2006ba
 static void sig_resize (int dont_care_sig) {
2006ba
 // POSIX.1-2004 async-signal-safe: tcdrain
2006ba
    tcdrain(STDOUT_FILENO);
2006ba
-   Frames_resize = RESIZ_sig;
2006ba
+   Frames_signal = BREAK_sig;
2006ba
    (void)dont_care_sig;
2006ba
 } // end: sig_resize
2006ba
 
2006ba
@@ -928,12 +929,13 @@ static inline int ioa (struct timespec *ts) {
2006ba
    FD_ZERO(&fs);
2006ba
    FD_SET(STDIN_FILENO, &fs);
2006ba
 
2006ba
-#ifndef SIGNALS_LESS // conditional comments are silly, but help in documenting
2006ba
-   // hold here until we've got keyboard input, any signal (including SIGWINCH)
2006ba
-#else
2006ba
+#ifdef SIGNALS_LESS // conditional comments are silly, but help in documenting
2006ba
    // hold here until we've got keyboard input, any signal except SIGWINCH
2006ba
-#endif
2006ba
    // or (optionally) we timeout with nanosecond granularity
2006ba
+#else
2006ba
+   // hold here until we've got keyboard input, any signal (including SIGWINCH)
2006ba
+   // or (optionally) we timeout with nanosecond granularity
2006ba
+#endif
2006ba
    rc = pselect(STDIN_FILENO + 1, &fs, NULL, NULL, ts, &Sigwinch_set);
2006ba
 
2006ba
    if (rc < 0) rc = 0;
2006ba
@@ -1263,7 +1265,7 @@ static float get_float (const char *prompt) {
2006ba
    float f;
2006ba
 
2006ba
    line = ioline(prompt);
2006ba
-   if (!line[0] || Frames_resize) return -1.0;
2006ba
+   if (!line[0] || Frames_signal) return -1.0;
2006ba
    // note: we're not allowing negative floats
2006ba
    if (strcspn(line, "+,.0123456789")) {
2006ba
       show_msg(N_txt(BAD_numfloat_txt));
2006ba
@@ -1284,7 +1286,7 @@ static int get_int (const char *prompt) {
2006ba
    int n;
2006ba
 
2006ba
    line = ioline(prompt);
2006ba
-   if (Frames_resize) return GET_INT_BAD;
2006ba
+   if (Frames_signal) return GET_INT_BAD;
2006ba
    if (!line[0]) return GET_INTNONE;
2006ba
    // note: we've got to allow negative ints (renice)
2006ba
    if (strcspn(line, "-+0123456789")) {
2006ba
@@ -1822,7 +1824,7 @@ static void adj_geometry (void) {
2006ba
    PSU_CLREOS(0);
2006ba
 
2006ba
    fflush(stdout);
2006ba
-   Frames_resize = RESIZ_clr;
2006ba
+   Frames_signal = BREAK_off;
2006ba
 } // end: adj_geometry
2006ba
 
2006ba
 
2006ba
@@ -2134,7 +2136,7 @@ signify_that:
2006ba
       display_fields(i, (p != NULL));
2006ba
       fflush(stdout);
2006ba
 
2006ba
-      if (Frames_resize) goto signify_that;
2006ba
+      if (Frames_signal) goto signify_that;
2006ba
       key = iokey(1);
2006ba
       if (key < 1) goto signify_that;
2006ba
 
2006ba
@@ -3053,7 +3055,7 @@ signify_that:
2006ba
          lest repeated <Enter> keys produce immediate re-selection in caller */
2006ba
       tcflush(STDIN_FILENO, TCIFLUSH);
2006ba
 
2006ba
-      if (Frames_resize) goto signify_that;
2006ba
+      if (Frames_signal) goto signify_that;
2006ba
       key = iokey(1);
2006ba
       if (key < 1) goto signify_that;
2006ba
 
2006ba
@@ -3158,7 +3160,7 @@ signify_that:
2006ba
          , pid, p->cmd, p->euser, sels));
2006ba
       INSP_MKSL(0, " ");
2006ba
 
2006ba
-      if (Frames_resize) goto signify_that;
2006ba
+      if (Frames_signal) goto signify_that;
2006ba
       if (key == INT_MAX) key = iokey(1);
2006ba
       if (key < 1) goto signify_that;
2006ba
 
2006ba
@@ -3903,7 +3905,7 @@ signify_that:
2006ba
       putp(Cap_clr_eos);
2006ba
       fflush(stdout);
2006ba
 
2006ba
-      if (Frames_resize) goto signify_that;
2006ba
+      if (Frames_signal) goto signify_that;
2006ba
       key = iokey(1);
2006ba
       if (key < 1) goto signify_that;
2006ba
 
2006ba
@@ -4135,7 +4137,7 @@ signify_that:
2006ba
    putp(Cap_clr_eos);
2006ba
    fflush(stdout);
2006ba
 
2006ba
-   if (Frames_resize) goto signify_that;
2006ba
+   if (Frames_signal) goto signify_that;
2006ba
    key = iokey(1);
2006ba
    if (key < 1) goto signify_that;
2006ba
 
2006ba
@@ -4151,7 +4153,7 @@ signify_that:
2006ba
                , Winstk[2].rc.winname, Winstk[3].rc.winname));
2006ba
             putp(Cap_clr_eos);
2006ba
             fflush(stdout);
2006ba
-            if (Frames_resize || (key = iokey(1)) < 1) {
2006ba
+            if (Frames_signal || (key = iokey(1)) < 1) {
2006ba
                adj_geometry();
2006ba
                putp(Cap_clr_scr);
2006ba
             } else w = win_select(key);
2006ba
@@ -4341,7 +4343,7 @@ static void keys_global (int ch) {
2006ba
                if (0 > pid) pid = def;
2006ba
                str = ioline(fmtmk(N_fmt(GET_sigs_num_fmt), pid, SIGTERM));
2006ba
                if (*str) sig = signal_name_to_number(str);
2006ba
-               if (Frames_resize) break;
2006ba
+               if (Frames_signal) break;
2006ba
                if (0 < sig && kill(pid, sig))
2006ba
                   show_msg(fmtmk(N_fmt(FAIL_signals_fmt)
2006ba
                      , pid, sig, strerror(errno)));
2006ba
@@ -4909,12 +4911,12 @@ static void do_key (int ch) {
2006ba
          for (i = 0; i < MAXTBL(key_tab); ++i)
2006ba
             if (strchr(key_tab[i].keys, ch)) {
2006ba
                key_tab[i].func(ch);
2006ba
-               Frames_resize = RESIZ_kbd;
2006ba
+               Frames_signal = BREAK_kbd;
2006ba
                putp((Cursor_state = Cap_curs_hide));
2006ba
                return;
2006ba
             }
2006ba
    };
2006ba
-   /* Frames_resize above will force a rebuild of all column headers and
2006ba
+   /* Frames_signal above will force a rebuild of all column headers and
2006ba
       the PROC_FILLxxx flags.  It's NOT simply lazy programming.  Here are
2006ba
       some keys that COULD require new column headers and/or libproc flags:
2006ba
          'A' - likely
2006ba
@@ -5458,7 +5460,7 @@ static void frame_make (void) {
2006ba
    int i, scrlins;
2006ba
 
2006ba
    // deal with potential signal(s) since the last time around...
2006ba
-   if (Frames_resize)
2006ba
+   if (Frames_signal)
2006ba
       zap_fieldstab();
2006ba
 
2006ba
    // whoa either first time or thread/task mode change, (re)prime the pump...
2006ba
@@ -5549,7 +5551,7 @@ int main (int dont_care_argc, char **argv) {
2006ba
                     produce a screen refresh. in this main loop frame_make
2006ba
                     assumes responsibility for such refreshes. other logic
2006ba
                     in contact with users must deal more obliquely with an
2006ba
-                    interrupt/refresh (hint: Frames_resize + return code)!
2006ba
+                    interrupt/refresh (hint: Frames_signal + return code)!
2006ba
 
2006ba
                     (everything is perfectly justified plus right margins)
2006ba
                     (are completely filled, but of course it must be luck)
2006ba
diff --git a/top/top.h b/top/top.h
2006ba
index a8a7357..43d1ebc 100644
2006ba
--- a/top/top.h
2006ba
+++ b/top/top.h
2006ba
@@ -208,9 +208,9 @@ enum scale_enum {
2006ba
    SK_Kb, SK_Mb, SK_Gb, SK_Tb, SK_Pb, SK_Eb, SK_SENTINEL
2006ba
 };
2006ba
 
2006ba
-        /* Used to manipulate (and document) the Frames_resize states */
2006ba
+        /* Used to manipulate (and document) the Frames_signal states */
2006ba
 enum resize_states {
2006ba
-   RESIZ_clr, RESIZ_kbd, RESIZ_sig
2006ba
+   BREAK_off = 0, BREAK_kbd, BREAK_sig
2006ba
 };
2006ba
 
2006ba
         /* This typedef just ensures consistent 'process flags' handling */
2006ba
-- 
2006ba
1.8.1.2
2006ba