procps-ng/0001-top-refine-some-miscellaneous-signals-interrupt-stuf.patch

233 lines
8.6 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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