Dr. Werner Fink 2014-05-15 12:14:34 +00:00 committed by Git OBS Bridge
parent 19d965e67b
commit 6bb1b29906
34 changed files with 3296 additions and 103 deletions

View File

@ -1,4 +1,4 @@
From a6dfe2648a39d5fed8de0361aecf0e035ad80222 Mon Sep 17 00:00:00 2001
From b55f9b97db9101e8fb1903d03f7bc7e9c8476572 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 6 Jun 2013 00:00:00 -0500
Subject: [PATCH] top: add the major version to dlopen of libnuma soname
@ -21,13 +21,13 @@ commit edba932a7e9b950dd91bc486e107788e977a5186
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 2 +-
top/top.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/top/top.c b/top/top.c
index c1853ee..1d38c0f 100644
--- a/top/top.c
+++ b/top/top.c
diff --git top/top.c top/top.c
index 2b05a60..0d7ee2d 100644
--- top/top.c
+++ top/top.c
@@ -3246,7 +3246,7 @@ static void before (char *me) {
#if defined(PRETEND_NUMA) || defined(PRETEND8CPUS)
Numa_node_tot = Numa_max_node() + 1;
@ -38,5 +38,5 @@ index c1853ee..1d38c0f 100644
Numa_max_node = dlsym(Libnuma_handle, "numa_max_node");
Numa_node_of_cpu = dlsym(Libnuma_handle, "numa_node_of_cpu");
--
1.8.1.2
1.7.9.2

View File

@ -1,7 +1,7 @@
From 2c19223cf286a9f47fd95e557b1644ed44625b9a Mon Sep 17 00:00:00 2001
From b79b927f9781c02c82f906bf8bc5aa16c5df2a87 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 20 Jun 2013 00:00:00 -0500
Subject: [PATCH 1/2] top: trade two groff_mdoc macros for groff equivalents
Subject: [PATCH] top: trade two groff_mdoc macros for groff equivalents
The .Bd and .Ed macros, from the mdoc collection, have
caused a few raised eyebrows (lintian, doclifter, etc)
@ -10,13 +10,13 @@ for the standard existing groff .nf & .fi equivalents.
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.1 | 155 +++++++++++++++++++++++++++++++-------------------------------
top/top.1 | 155 +++++++++++++++++++++++++++++++------------------------------
1 file changed, 78 insertions(+), 77 deletions(-)
diff --git a/top/top.1 b/top/top.1
diff --git top/top.1 top/top.1
index 53ebaf2..0a753a8 100644
--- a/top/top.1
+++ b/top/top.1
--- top/top.1
+++ top/top.1
@@ -118,7 +118,7 @@ display and used when reading and writing a \*(CF.
.\" ----------------------------------------------------------------------
The remaining Table of Contents
@ -566,5 +566,5 @@ index 53ebaf2..0a753a8 100644
What you'll see is a very busy Linux doing what he's always done for you,
but there was no program available to illustrate this.
--
1.8.1.2
1.7.9.2

View File

@ -1,7 +1,7 @@
From b1f06bdcc9e02f7dbaf1161ad6231c45ea3f9d88 Mon Sep 17 00:00:00 2001
From ce5e995921e770bfcda25e42fe090aeccdbf1291 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Tue, 25 Jun 2013 00:00:00 -0500
Subject: [PATCH 2/2] library: for atexit() support, fix fileutils for EPIPE
Subject: [PATCH] library: for atexit() support, fix fileutils for EPIPE
When fileutils with stream error checking was borrowed
from GNU lib, an omission was also propagated where an
@ -21,13 +21,13 @@ commit c7cf98b0e03780f78abe5275c6fb282f71a2369f
. bugzilla report
https://bugzilla.redhat.com/show_bug.cgi?id=976199
---
lib/fileutils.c | 2 +-
lib/fileutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fileutils.c b/lib/fileutils.c
diff --git lib/fileutils.c lib/fileutils.c
index a9ef2ff..1ade3d8 100644
--- a/lib/fileutils.c
+++ b/lib/fileutils.c
--- lib/fileutils.c
+++ lib/fileutils.c
@@ -24,7 +24,7 @@ int close_stream(FILE * stream)
const int prev_fail = (ferror(stream) != 0);
const int fclose_fail = (fclose(stream) != 0);
@ -38,5 +38,5 @@ index a9ef2ff..1ade3d8 100644
return EOF;
}
--
1.8.1.2
1.7.9.2

View File

@ -1,13 +1,64 @@
Signed-off-by: Jim Warner <james.warner@xxxxxxxxxxx>
From 5c974ff44da4fbbb9170dd15bdd81555c62c31a9 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 28 Jun 2013 00:00:00 -0500
Subject: [PATCH] top: enable screen contents preservation at end-of-job
The title of this commit is actually quite misleading.
Were it more accurate, it would at least mention a tty
emulator's scrollback buffer, which was the cumulation
of a long pursuit to reduce the SIGWINCH overhead when
a window manager carelessly floods an application with
that signal *while* a user is still resizing a window!
Disabling and enabling that scrollback buffer resulted
in the final top display replaced with original screen
contents, a phenomenon acknowledged at the time but it
also represented a user interface change which has now
produced the first request for return to old behavior.
After the SIGWINCH dust settled, another problem arose
regarding behaviors under the 'screen' window manager.
In response, top was refactored a bit to avoid display
corruption. That was before discovering 'screen' could
duplicate the scrollback buffer behavior top expected.
As it turns out, the 'screen' refactoring had probably
made scrollback buffer manipulation unnecessary. Still
one could argue that a window should not be allowed to
scroll while a constantly updating program was active.
The solution represented in this commit returns former
behavior at program end (retaining top's last screen).
And if we ever wish to disable scrollback buffers, the
associated logic was retained but made conditional. It
is not reflected in configure.ac but might be someday.
Lastly, this commit corrects cursor positioning when a
^C is issued under 'Fields Management' at any terminal
that didn't have a scrollback buffer (i.e. a console).
Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=977561
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,1
. screen program refactor
commit 0fe393ff270922cd4f6edbcaabba006314e73a37
. scrollback buffer disabled
commit dedaf6e1a81738ff08ee8e8523871e12f555ad6d
. sigwinch management defines
commit adca737758e5afc7be344a736953931894cbc19f
commit 4f33b6b8c56464b4044deb29a3bb0e32622e108f
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 18 +++++++++++-------
top/top.h | 1 +
top/top.c | 18 +++++++++++-------
top/top.h | 1 +
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/top/top.c b/top/top.c
index 1d38c0f..cdcf3c0 100644
--- a/top/top.c
+++ b/top/top.c
diff --git top/top.c top/top.c
index 0d7ee2d..07217c8 100644
--- top/top.c
+++ top/top.c
@@ -72,8 +72,9 @@ static struct termios Tty_original, // our inherited terminal definition
Tty_raw; // for unsolicited input
static int Ttychanged = 0;
@ -82,10 +133,10 @@ index 1d38c0f..cdcf3c0 100644
// and don't forget to ask iokey to initialize his tinfo_tab
iokey(0);
} // end: whack_terminal
diff --git a/top/top.h b/top/top.h
diff --git top/top.h top/top.h
index f356798..a8a7357 100644
--- a/top/top.h
+++ b/top/top.h
--- top/top.h
+++ top/top.h
@@ -41,6 +41,7 @@
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
@ -95,4 +146,5 @@ index f356798..a8a7357 100644
//#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */
//#define PRETEND8CPUS /* pretend we're smp with 8 ticsers (sic) */
--
1.8.1.2
1.7.9.2

View File

@ -1,7 +1,7 @@
From e5d1a884f4e780aca7f9eaf68a51b967f9b43abf Mon Sep 17 00:00:00 2001
From 25ed080eaa9cec603bc486b47b4a96d6438cf94f 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
Subject: [PATCH] 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
@ -9,14 +9,14 @@ 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 ++--
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
diff --git top/top.c top/top.c
index 07217c8..cb7f3b8 100644
--- top/top.c
+++ 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 ]
@ -211,10 +211,10 @@ index cdcf3c0..c1c61dd 100644
(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
diff --git top/top.h top/top.h
index a8a7357..43d1ebc 100644
--- a/top/top.h
+++ b/top/top.h
--- top/top.h
+++ top/top.h
@@ -208,9 +208,9 @@ enum scale_enum {
SK_Kb, SK_Mb, SK_Gb, SK_Tb, SK_Pb, SK_Eb, SK_SENTINEL
};
@ -228,5 +228,5 @@ index a8a7357..43d1ebc 100644
/* This typedef just ensures consistent 'process flags' handling */
--
1.8.1.2
1.7.9.2

View File

@ -1,7 +1,7 @@
From eee15b862dd5b051f16c719bf3c974591783a8f8 Mon Sep 17 00:00:00 2001
From 33104a2bcc321495107d72e4cfee4090b1d90f76 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Mon, 1 Jul 2013 00:00:00 -0500
Subject: [PATCH 2/2] top: cursor repositioning includes line oriented input
Subject: [PATCH] top: cursor repositioning includes line oriented input
A recent patch introduced the ability to recognize the
need to reposition the cursor at suspension or program
@ -17,13 +17,13 @@ commit 5c974ff44da4fbbb9170dd15bdd81555c62c31a9
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 4 ++++
top/top.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/top/top.c b/top/top.c
index c1c61dd..138f3ee 100644
--- a/top/top.c
+++ b/top/top.c
diff --git top/top.c top/top.c
index cb7f3b8..223ed70 100644
--- top/top.c
+++ top/top.c
@@ -1081,12 +1081,14 @@ static char *ioline (const char *prompt) {
static char buf[MEDBUFSIZ];
char *p;
@ -56,5 +56,5 @@ index c1c61dd..138f3ee 100644
for (i = 0, plin = anchor; ; i++) {
#ifdef RECALL_FIXED
--
1.8.1.2
1.7.9.2

View File

@ -0,0 +1,63 @@
From 6967bf80a61fa42d8b02b08c358ea582a02f6856 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 4 Jul 2013 00:00:00 -0500
Subject: [PATCH] top: correct, improve or otherwise tweak some comments
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git top/top.c top/top.c
index 223ed70..978071c 100644
--- top/top.c
+++ top/top.c
@@ -2794,7 +2794,7 @@ static void insp_cnt_nl (void) {
Insp_p[0] = Insp_buf;
Insp_p[Insp_nl++] = cur;
Insp_p[Insp_nl] = end;
- if ((end - cur) == 1) // if there's a eof null delimiter,
+ if ((end - cur) == 1) // if there's an eof null delimiter,
--Insp_nl; // don't count it as a new line
} // end: insp_cnt_nl
@@ -3824,12 +3824,12 @@ static WIN_t *win_select (int ch) {
if (1 > (ch = iokey(1))) return w;
}
switch (ch) {
- case 'a': // we don't carry 'a' / 'w' in our
- w = w->next; // pmt - they're here for a good
- break; // friend of ours -- wins_colors.
- case 'w': // (however those letters work via
- w = w->prev; // the pmt too but gee, end-loser
- break; // should just press the darn key)
+ case 'a': // we don't carry 'a' / 'w' in our
+ w = w->next; // pmt - they're here for a good
+ break; // friend of ours -- wins_colors.
+ case 'w': // (however those letters work via
+ w = w->prev; // the pmt too but gee, end-loser
+ break; // should just press the darn key)
case '1': case '2' : case '3': case '4':
w = &Winstk[ch - '1'];
break;
@@ -5483,6 +5483,7 @@ static void frame_make (void) {
Max_lines = (Screen_rows - Msg_row) - 1;
OFFw(w, INFINDS_xxx);
+ // one way or another, rid us of any prior frame's msg
if (VIZISw(w) && CHKw(w, View_SCROLL)) show_scroll();
else PUTT("%s%s", tg2(0, Msg_row), Cap_clr_eol);
@@ -5501,8 +5502,7 @@ static void frame_make (void) {
}
}
- /* clear to end-of-screen (critical if last window is 'idleps off'),
- then put the cursor in-its-place, and rid us of any prior frame's msg
+ /* clear to end-of-screen - critical if last window is 'idleps off'
(main loop must iterate such that we're always called before sleep) */
if (scrlins < Max_lines) {
putp(Cap_nl_clreos);
--
1.7.9.2

View File

@ -0,0 +1,66 @@
From 30e90e426980c3122c668dd2a6b9236d4db6e048 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 5 Jul 2013 00:00:00 -0500
Subject: [PATCH] top: tweak cursor state code to swat an obscure buglet
An obscure bug has been discovered where a 'W' with an
old rcfile, warning against overwrite, would display a
cursor that should normally be hidden. This followed a
user's reply. So some logic was rearranged just a bit.
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git top/top.c top/top.c
index 978071c..8978cd1 100644
--- top/top.c
+++ top/top.c
@@ -3104,6 +3104,7 @@ signify_that:
case '/':
case 'n':
insp_find_str(key, &curcol, &curlin);
+ // must re-hide cursor in case a prompt for a string makes it huge
putp((Cursor_state = Cap_curs_hide));
break;
case '=':
@@ -4901,23 +4902,21 @@ static void do_key (int ch) {
};
int i;
- putp((Cursor_state = Cap_curs_hide));
switch (ch) {
case 0: // ignored (always)
case kbd_ESC: // ignored (sometimes)
- return;
+ goto all_done;
case 'q': // no return from this guy
bye_bye(NULL);
case 'W': // no need for rebuilds
write_rcfile();
- return;
+ goto all_done;
default: // and now, the real work...
for (i = 0; i < MAXTBL(key_tab); ++i)
if (strchr(key_tab[i].keys, ch)) {
key_tab[i].func(ch);
Frames_signal = BREAK_kbd;
- putp((Cursor_state = Cap_curs_hide));
- return;
+ goto all_done;
}
};
/* Frames_signal above will force a rebuild of all column headers and
@@ -4943,6 +4942,8 @@ static void do_key (int ch) {
*/
show_msg(N_txt(UNKNOWN_cmds_txt));
+all_done:
+ putp((Cursor_state = Cap_curs_hide));
} // end: do_key
--
1.7.9.2

View File

@ -0,0 +1,130 @@
From 46a1356219cfab67240704af9cd73b58a20d4232 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sat, 6 Jul 2013 00:00:00 -0500
Subject: [PATCH] top: correct cursor positioning for all ^Z or ^C cases
Some more (very obscure) conditions where a suspension
or program end might embed the shell prompt within top
output have been uncovered beyond the 2 already known.
We had already covered some suspend/end contingencies:
1. the users were using the 'fields management' screen
2. the users were prompted for any line oriented input
However, there remained some situations where ^Z or ^C
could still produce a misplaced cursor + shell prompt:
3. the 'g' command while waiting for the window choice
4. the 'W' command if about to overwrite an old rcfile
5. the '=' command when exploiting the Inspect feature
6. the period during which any error message was shown
But, even when all those bases are covered there still
remains a remote possibility that such interrupts will
occur during a top repaint cycle. So rather than throw
yet more code at these self-inflicted problems perhaps
it is better if we just throw in the proverbial towel.
Thus, I'll take the only sane approach and restore the
results expected ever since top's inception and before
scrollback buffers entered the picture. Namely, with a
^Z or ^C the cursor will be placed on the final screen
row. That usually means it will immediately follow the
last output line but it may follow many blank lines if
the user interrupts top when *not* on the main screen.
Reference(s):
. expanded repositioning (for line oriented input)
commit 33104a2bcc321495107d72e4cfee4090b1d90f76
. introduced repositioning (for fields management)
commit 5c974ff44da4fbbb9170dd15bdd81555c62c31a9
. scrollback buffers (the cursor handling changes)
commit dedaf6e1a81738ff08ee8e8523871e12f555ad6d
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git top/top.c top/top.c
index 8978cd1..e2451f5 100644
--- top/top.c
+++ top/top.c
@@ -72,9 +72,8 @@ static struct termios Tty_original, // our inherited terminal definition
Tty_raw; // for unsolicited input
static int Ttychanged = 0;
- /* Last established cursor state/shape, and is re-position needed */
+ /* Last established cursor state/shape */
static const char *Cursor_state = "";
-static int Cursor_repos;
/* Program name used in error messages and local 'rc' file name */
static char *Myname;
@@ -351,7 +350,7 @@ static void at_eoj (void) {
if (Ttychanged) {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &Tty_original);
if (keypad_local) putp(keypad_local);
- if (Cursor_repos) putp(tg2(0, Screen_rows));
+ putp(tg2(0, Screen_rows));
putp("\n");
#ifdef OFF_SCROLLBK
if (exit_ca_mode) {
@@ -602,7 +601,7 @@ static void sig_paused (int dont_care_sig) {
if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &Tty_original))
error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
if (keypad_local) putp(keypad_local);
- if (Cursor_repos) putp(tg2(0, Screen_rows));
+ putp(tg2(0, Screen_rows));
putp(Cap_curs_norm);
#ifndef RMAN_IGNORED
putp(Cap_smam);
@@ -1081,14 +1080,12 @@ static char *ioline (const char *prompt) {
static char buf[MEDBUFSIZ];
char *p;
- Cursor_repos = 1;
show_pmt(prompt);
memset(buf, '\0', sizeof(buf));
ioch(1, buf, sizeof(buf)-1);
if ((p = strpbrk(buf, ws))) *p = '\0';
// note: we DO produce a vaid 'string'
- Cursor_repos = 0;
return buf;
} // end: ioline
@@ -1119,7 +1116,6 @@ static char *ioline (const char *prompt) {
};
static struct lin_s *anchor, *plin;
- Cursor_repos = 1;
if (!anchor) {
anchor = alloc_c(sizeof(struct lin_s));
anchor->str = alloc_s(""); // top-of-stack == empty str
@@ -1185,7 +1181,6 @@ static char *ioline (const char *prompt) {
putp(tg2(beg+pos, Msg_row));
} while (key && key != kbd_ENTER && key != kbd_ESC);
- Cursor_repos = 0;
// weed out duplicates, including empty strings (top-of-stack)...
for (i = 0, plin = anchor; ; i++) {
#ifdef RECALL_FIXED
@@ -2126,7 +2121,6 @@ static void fields_utility (void) {
int i, key;
FLG_t f;
- Cursor_repos = 1;
spewFI
signify_that:
putp(Cap_clr_scr);
@@ -2187,7 +2181,6 @@ signify_that:
break;
}
} while (key != 'q' && key != kbd_ESC);
- Cursor_repos = 0;
#undef unSCRL
#undef swapEM
#undef spewFI
--
1.7.9.2

View File

@ -0,0 +1,33 @@
From 7c4894dd222ff951e9b8a7efce00a9d9ab9ee586 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 7 Aug 2013 12:58:57 -0500
Subject: [PATCH] ps: address a potential 'newline' quirk the libselinux
Sometimes with libselinux present but SELinux inactive
the context reported is "unconfined" which contains an
embedded newline. This then causes misalignment of any
subsequent data. So, ps will now protect against that.
Reference(s):
http://www.freelists.org/post/procps/enablelibselinux-switch,14
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
ps/output.c | 1 +
1 file changed, 1 insertion(+)
diff --git ps/output.c ps/output.c
index b7b21d1..d457a89 100644
--- ps/output.c
+++ ps/output.c
@@ -1339,6 +1339,7 @@ static int pr_context(char *restrict const outbuf, const proc_t *restrict const
len = strlen(context);
if(len > max_len) len = max_len;
memcpy(outbuf, context, len);
+ if (outbuf[len-1] == '\n') --len;
outbuf[len] = '\0';
free(context);
}else{
--
1.7.9.2

View File

@ -0,0 +1,33 @@
From 739effd90701d5d327624cd833d20c7f35981613 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 9 Aug 2013 00:00:00 -0500
Subject: [PATCH] top: hint that Summary Area 'cached' is Mem (not Swap)
This patch just provides a visual clue to separate the
values reported for cached Memory from other values on
the Swapped line (which is being shared due to space).
Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718670
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top_nls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git top/top_nls.c top/top_nls.c
index fa6969e..25c7f56 100644
--- top/top_nls.c
+++ top/top_nls.c
@@ -618,7 +618,7 @@ static void build_uniq_nlstab (void) {
. words: total, used, free, buffers, cached */
Uniq_nlstab[MEMORY_lines_fmt] = _(""
"%s Mem: ~3 %9.9s~2total,~3 %9.9s~2used,~3 %9.9s~2free,~3 %9.9s~2buffers~3\n"
- "%s Swap:~3 %9.9s~2total,~3 %9.9s~2used,~3 %9.9s~2free,~3 %9.9s~2cached~3\n");
+ "%s Swap:~3 %9.9s~2total,~3 %9.9s~2used,~3 %9.9s~2free.~3 %9.9s~2cached Mem~3\n");
Uniq_nlstab[INSP_hdrsels_fmt] = _(""
"Inspection~2 Pause at: pid ~1%d~6 running ~1%s~6 as user ~1%s~6\n"
--
1.7.9.2

View File

@ -0,0 +1,97 @@
From 80e678343653ccadaaf66bf719b3da9d6168d9ec Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 15 Aug 2013 00:00:00 -0500
Subject: [PATCH] top: modest efficiency change to message line handling
When the final solution for cursor positioning for all
^Z or ^C cases was introduced the revised placement of
message line management introduced with the window mgr
'screen' refactor was retained. Those two commits mean
that a former tgoto was no longer needed when clearing
that msg line or displaying the scroll coordinate msg.
This patch eliminates the tgoto employed by frame_make
while assimilating a now defunct show_scroll function.
Reference(s):
. final cursor positioning for ^Z or ^C
commit 46a1356219cfab67240704af9cd73b58a20d4232
. 'screen' window manager refactor
commit 0fe393ff270922cd4f6edbcaabba006314e73a37
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 22 ++++++++++------------
top/top.h | 1 -
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git top/top.c top/top.c
index e2451f5..c29bb07 100644
--- top/top.c
+++ top/top.c
@@ -751,13 +751,6 @@ static int show_pmt (const char *str) {
/*
- * Show a special coordinate message, in support of scrolling */
-static inline void show_scroll (void) {
- PUTT(Scroll_fmts, tg2(0, Msg_row), Frame_maxtask);
-} // end: show_scroll
-
-
- /*
* Show lines with specially formatted elements, but only output
* what will fit within the current screen width.
* Our special formatting consists of:
@@ -857,7 +850,7 @@ static void show_special (int interact, const char *glob) {
/*
* Create a nearly complete scroll coordinates message, but still
- * a format string since we'll be missing a tgoto and total tasks. */
+ * a format string since we'll be missing the current total tasks. */
static void updt_scroll_msg (void) {
char tmp1[SMLBUFSIZ], tmp2[SMLBUFSIZ];
int totpflgs = Curwin->totpflgs;
@@ -878,8 +871,10 @@ static void updt_scroll_msg (void) {
if (Curwin->varcolbeg)
snprintf(tmp2, sizeof(tmp2), "%s + %d", tmp1, Curwin->varcolbeg);
#endif
+ // this Scroll_fmts string no longer provides for termcap tgoto so that
+ // the usage timing is critical -- see frame_make() for additional info
snprintf(Scroll_fmts, sizeof(Scroll_fmts)
- , "%%s%s %.*s%s", Caps_off, Screen_cols - 3, tmp2, Cap_clr_eol);
+ , "%s %.*s%s", Caps_off, Screen_cols - 3, tmp2, Cap_clr_eol);
} // end: updt_scroll_msg
/*###### Low Level Memory/Keyboard/File I/O support ####################*/
@@ -5477,9 +5472,12 @@ static void frame_make (void) {
Max_lines = (Screen_rows - Msg_row) - 1;
OFFw(w, INFINDS_xxx);
- // one way or another, rid us of any prior frame's msg
- if (VIZISw(w) && CHKw(w, View_SCROLL)) show_scroll();
- else PUTT("%s%s", tg2(0, Msg_row), Cap_clr_eol);
+ /* one way or another, rid us of any prior frame's msg
+ [ now that this is positioned after the call to summary_show(), ]
+ [ we no longer need or employ tg2(0, Msg_row) since all summary ]
+ [ lines end with a newline, and header lines begin with newline ] */
+ if (VIZISw(w) && CHKw(w, View_SCROLL)) PUTT(Scroll_fmts, Frame_maxtask);
+ else putp(Cap_clr_eol);
if (!Rc.mode_altscr) {
// only 1 window to show so, piece o' cake
diff --git top/top.h top/top.h
index 43d1ebc..017644f 100644
--- top/top.h
+++ top/top.h
@@ -658,7 +658,6 @@ typedef struct WIN_t {
//atic void capsmk (WIN_t *q);
//atic void show_msg (const char *str);
//atic int show_pmt (const char *str);
-//atic inline void show_scroll (void);
//atic void show_special (int interact, const char *glob);
//atic void updt_scroll_msg (void);
/*------ Low Level Memory/Keyboard/File I/O support --------------------*/
--
1.7.9.2

View File

@ -0,0 +1,104 @@
From 819ede1a6bc25d732cf84d15c48be9ca86f336a2 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Tue, 20 Aug 2013 00:00:00 -0500
Subject: [PATCH] top: correct, improve and otherwise tweak configs_read
This patch addresses the four '-Wunused-result' errors
generated whenever an optimized compile is invoked. It
also made the configs_read() guy a little more robust.
In the process, some logic was rearranged slightly and
some comments were re-indented simply for consistency.
Reference(s):
warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]
warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git top/top.c top/top.c
index c29bb07..bdfcf20 100644
--- top/top.c
+++ top/top.c
@@ -3394,26 +3394,25 @@ static void configs_read (void) {
fp = fopen(SYS_RCFILESPEC, "r");
if (fp) {
- fbuf[0] = '\0';
- fgets(fbuf, sizeof(fbuf), fp); // sys rc file, line 1
- if (strchr(fbuf, 's')) Secure_mode = 1;
- fbuf[0] = '\0';
- fgets(fbuf, sizeof(fbuf), fp); // sys rc file, line 2
- sscanf(fbuf, "%f", &Rc.delay_time);
+ if (fgets(fbuf, sizeof(fbuf), fp)) { // sys rc file, line 1
+ Secure_mode = 1;
+ if (fgets(fbuf, sizeof(fbuf), fp)) // sys rc file, line 2
+ sscanf(fbuf, "%f", &Rc.delay_time);
+ }
fclose(fp);
}
fp = fopen(Rc_name, "r");
if (fp) {
int tmp_whole, tmp_fract;
- fbuf[0] = '\0';
- fgets(fbuf, sizeof(fbuf), fp); // ignore eyecatcher
+ if (fgets(fbuf, sizeof(fbuf), fp)) // ignore eyecatcher
+ ; // avoid -Wunused-result
if (6 != fscanf(fp
, "Id:%c, Mode_altscr=%d, Mode_irixps=%d, Delay_time=%d.%d, Curwin=%d\n"
, &Rc.id, &Rc.mode_altscr, &Rc.mode_irixps, &tmp_whole, &tmp_fract, &i)) {
p = fmtmk(N_fmt(RC_bad_files_fmt), Rc_name);
Rc_questions = -1;
- goto try_inspect_entries; // maybe a faulty 'inspect' echo
+ goto try_inspect_entries; // maybe a faulty 'inspect' echo
}
// you saw that, right? (fscanf stickin' it to 'i')
Curwin = &Winstk[i];
@@ -3442,20 +3441,20 @@ static void configs_read (void) {
goto default_or_error;
switch (Rc.id) {
- case 'f': // 3.3.0 thru 3.3.3 (procps-ng)
- SETw(w, Show_JRNUMS); // fall through !
- case 'g': // current RCF_VERSION_ID
- default: // and future versions?
+ case 'a': // 3.2.8 (former procps)
+ if (config_cvt(w))
+ goto default_or_error;
+ break;
+ case 'f': // 3.3.0 thru 3.3.3 (procps-ng)
+ SETw(w, Show_JRNUMS); // fall through !
+ case 'g': // current RCF_VERSION_ID
+ default: // and future versions?
if (strlen(w->rc.fieldscur) != sizeof(DEF_FIELDS) - 1)
goto default_or_error;
for (x = 0; x < P_MAXPFLGS; ++x)
if (P_MAXPFLGS <= FLDget(w, x))
goto default_or_error;
break;
- case 'a': // 3.2.8 (former procps)
- if (config_cvt(w))
- goto default_or_error;
- break;
}
#ifndef USE_X_COLHDR
OFFw(w, NOHIFND_xxx | NOHISEL_xxx);
@@ -3463,8 +3462,9 @@ static void configs_read (void) {
} // end: for (GROUPSMAX)
// any new addition(s) last, for older rcfiles compatibility...
- fscanf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d\n"
- , &Rc.fixed_widest, &Rc.summ_mscale, &Rc.task_mscale, &Rc.zero_suppress);
+ if (fscanf(fp, "Fixed_widest=%d, Summ_mscale=%d, Task_mscale=%d, Zero_suppress=%d\n"
+ , &Rc.fixed_widest, &Rc.summ_mscale, &Rc.task_mscale, &Rc.zero_suppress))
+ ; // avoid -Wunused-result
try_inspect_entries:
// we'll start off Inspect stuff with 1 'potential' blank line
--
1.7.9.2

View File

@ -0,0 +1,39 @@
From 06c19f5ba4e8fcb704936609e8ef7d328ca54a28 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 29 Aug 2013 00:00:00 -0500
Subject: [PATCH] top: swat bug affecting batch mode and width provision
Normally, the internally tracked 'Screen_cols' can not
exceed the lessor of 512 or actual screen width. There
was one case, however, where that 512 byte upper limit
was no longer properly imposed as it should have been.
When operating in 'Batch' mode the actual screen width
was allowed to be exceeded when the optional -w switch
was also used. But, it should never have exceeded 512.
This patch ensures the upper limit is always observed.
Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721204
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 1 +
1 file changed, 1 insertion(+)
diff --git top/top.c top/top.c
index bdfcf20..9996fbf 100644
--- top/top.c
+++ top/top.c
@@ -1792,6 +1792,7 @@ static void adj_geometry (void) {
if (w_cols && w_cols < W_MIN_COL) w_cols = W_MIN_COL;
if (w_rows && w_rows < W_MIN_ROW) w_rows = W_MIN_ROW;
}
+ if (w_cols > SCREENMAX) w_cols = SCREENMAX;
w_set = 1;
}
--
1.7.9.2

View File

@ -0,0 +1,32 @@
From 4141efaf13254564f0377289bcf5a1a1389f60af Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Tue, 17 Sep 2013 00:00:00 -0500
Subject: [PATCH] top: restore the lost final newline when in Batch mode
This patch adds the final newline when exiting 'Batch'
mode. Interestingly, it has been missing since release
3.3.5 but undetected until the Redhat bugzilla report.
Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=1008674
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 1 +
1 file changed, 1 insertion(+)
diff --git top/top.c top/top.c
index 6f4f728..44bc380 100644
--- top/top.c
+++ top/top.c
@@ -527,6 +527,7 @@ static void bye_bye (const char *str) {
fputs(str, stderr);
exit(EXIT_FAILURE);
}
+ if (Batch) putp("\n");
exit(EXIT_SUCCESS);
} // end: bye_bye
--
1.7.9.2

View File

@ -0,0 +1,62 @@
From e6a78f2745ca6c7ceed4406d3ce5397e77518b11 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 27 Sep 2013 12:12:12 -0500
Subject: [PATCH] top: swat bug impacting 'idle' mode & 'user' filtering
When Other filtering was introduced the nature of what
constituted a displayed row changed. No longer would a
task_show() call guarantee that another line is shown.
Rather, a non-empty string must have also been tested.
Unfortunately, when any task window was being filtered
for 'idle' mode or a particular 'user', the proc index
was incremented twice due to the perils of copy/paste.
Combining such an index increment with the new test of
task_show results works fine if filtering is inactive.
This was a particularly insidious bug which meant that
an adjacent task would be skipped whenever the current
task met 'idle' and/or 'user' filter criteria, and was
not otherwise excluded due to 'Other' filter criteria.
And, since it was the very next task that was ignored,
the bug was very susceptible to a window's sort order.
This could be illustrated when filtering on some user,
while sorting on PID. Then, toggling Forest View could
make otherwise unseen tasks appear and then disappear.
User workarounds are possible via interactive commands
trading the 'i' and 'u'/'U' provisions for the 'o'/'O'
other filtering capability thus avoiding an extra i++.
But that is certainly less than ideal and doesn't help
the 3.3.7 and 3.3.8 distorted command line provisions.
( this little buggie may end up costing me my pocket )
( protector, my coding badge & maybe even my cubicle )
Reference(s):
http://www.freelists.org/post/procps/Idle-elides-nonidle-processes
. bug originated with 'Other' filtering
commit 5edc6fb3174f1fd02bbfca61ec6d8a3a2e12f71c
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git top/top.c top/top.c
index 44bc380..aa2777b 100644
--- top/top.c
+++ top/top.c
@@ -5399,7 +5399,7 @@ static int window_show (WIN_t *q, int wmax) {
while (i < Frame_maxtask && lwin < wmax) {
if ((CHKw(q, Show_IDLEPS) || isBUSY(q->ppt[i]))
&& user_matched(q, q->ppt[i])
- && *task_show(q, q->ppt[i++]))
+ && *task_show(q, q->ppt[i]))
++lwin;
++i;
}
--
1.7.9.2

View File

@ -0,0 +1,83 @@
From 35dc6dcc49cc9cf8cff4300cb03a38dbe44c05db Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sun, 3 Nov 2013 00:00:00 -0500
Subject: [PATCH] top: address some potential libnuma display corruption
There is a chance that the libnuma library may corrupt
top's display with some stderr warning messages in the
event something under /sys/devices/system/node/ cannot
be accessed. And, while 2 overridable 'weak' functions
are provided to alter such behavior, we can't use them
since top dynamically links to the library via dlopen.
This commit will redirect stderr to '/dev/null' during
just the first screen display cycle. Thus we can avoid
the corruption which would have remained visible until
the underlining screen row's data had finally changed.
Lastly, this patch should allow such a library warning
to actually appear when one finally exits our program.
[ i think the libnuma folks should consider changing ]
[ the error/warning interfaces to accommodate dlopen ]
[ rather than forcing something like the ugly kludge ]
[ we have employed or libnuma dependency on everyone ]
Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=998678
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git top/top.c top/top.c
index aa2777b..a48a5b9 100644
--- top/top.c
+++ top/top.c
@@ -220,6 +220,7 @@ static int Numa_node_tot;
static int Numa_node_sel = -1;
#ifndef NUMA_DISABLE
static void *Libnuma_handle;
+static int stderr_save = -1;
#if defined(PRETEND_NUMA) || defined(PRETEND8CPUS)
static int Numa_max_node(void) { return 3; }
static int Numa_node_of_cpu(int num) { return (num % 4); }
@@ -4043,6 +4044,17 @@ static void wins_stage_2 (void) {
// fill in missing Fieldstab members and build each window's columnhdr
zap_fieldstab();
+#ifndef NUMA_DISABLE
+ /* there's a chance that damn libnuma may spew to stderr so we gotta
+ make sure he does not corrupt poor ol' top's first output screen!
+ Yes, he provides some overridable 'weak' functions to change such
+ behavior but we can't exploit that since we don't follow a normal
+ ld route to symbol resolution (we use that dlopen() guy instead)! */
+ stderr_save = dup(fileno(stderr));
+ if (-1 < stderr_save && freopen("/dev/null", "w", stderr))
+ ; // avoid -Wunused-result
+#endif
+
// lastly, initialize a signal set used to throttle one troublesome signal
sigemptyset(&Sigwinch_set);
#ifdef SIGNALS_LESS
@@ -5508,6 +5520,16 @@ static void frame_make (void) {
the normal non-interactive output optimization... */
if (!Cap_can_goto) PSU_CLREOS(0);
+#ifndef NUMA_DISABLE
+ /* we gotta reverse the stderr redirect which was employed in wins_stage_2
+ and needed because the two libnuma 'weak' functions were useless to us! */
+ if (-1 < stderr_save) {
+ dup2(stderr_save, fileno(stderr));
+ close(stderr_save);
+ stderr_save = -1;
+ }
+#endif
+
/* lastly, check auto-sized width needs for the next iteration */
if (AUTOX_MODE && Autox_found)
widths_resize();
--
1.7.9.2

View File

@ -0,0 +1,76 @@
From 5a8adee659524ef72583d8ea494721d279b5bea1 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Tue, 5 Nov 2013 00:00:00 -0600
Subject: [PATCH] top: fix miscellaneous spelling errors in man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
procps-ng-3.3.8/top/top.1 | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
--- top/top.1
+++ top/top.1 2014-05-15 10:27:04.482756345 +0000
@@ -383,8 +383,8 @@ Display only processes with a user id or
The '\-u' option matches on \fI effective\fR user whereas the '\-U' option
matches on\fI any\fR user (real, effective, saved, or filesystem).
-Prepending an exclamation point ('!') to the user id or name instucts top to
-display only processes with users not matching the one provided.
+Prepending an exclamation point ('!') to the user id or name instructs top
+to display only processes with users not matching the one provided.
The 'p', 'u' and 'U' \*(COs are mutually exclusive.
@@ -650,8 +650,8 @@ If you see 'rt' in this field, it means
'real time' scheduling priority.
Under linux, real time priority is somewhat misleading since traditionally
-the operating itself was not preemptable.
-And while the 2.6 kernel can be made mostly preemptable, it is not always so.
+the operating itself was not preemptible.
+And while the 2.6 kernel can be made mostly preemptible, it is not always so.
.TP 4
17.\fB RES \*(Em Resident Memory Size (KiB) \fR
@@ -1337,10 +1337,10 @@ matches on\fB any\fR user (real, effecti
Thereafter, in that \*(TW only matching users will be shown, or possibly
no processes will be shown.
-Prepending an exclamation point ('!') to the user id or name instucts top
+Prepending an exclamation point ('!') to the user id or name instructs top
to display only processes with users not matching the one provided.
-Different \*(TWs can can be used to filter different users.
+Different \*(TWs can be used to filter different users.
Later, if you wish to monitor all users again in the \*(CW, re-issue this
command but just press <Enter> at the prompt.
@@ -1349,7 +1349,7 @@ command but just press <Enter> at the pr
In this mode, processes are reordered according to their parents and
the layout of the COMMAND column resembles that of a tree.
In forest view mode it is still possible to toggle between program
-name and commamd line (\*(Xc 'c' \*(CI) or between processes and
+name and command line (\*(Xc 'c' \*(CI) or between processes and
threads (\*(Xc 'H' \*(CI).
\*(NT Typing any key affecting the sort order will exit forest view
@@ -1673,8 +1673,8 @@ The above \*(CIs are\fB always\fR availa
available in \*(AM if the \*(CW's \*(TD has been toggled \*F.
\*(NT When any form of filtering is active, you can expect some slight
-abberations when scrolling since not all tasks will be visible.
-This is paticularly apparent when using the Up/Down \*(KAs.
+aberrations when scrolling since not all tasks will be visible.
+This is particularly apparent when using the Up/Down \*(KAs.
.\" ......................................................................
.SS 5d. SEARCHING in a Window
@@ -2037,7 +2037,7 @@ enable backslash interpretation regardle
\fBCaution\fR:
If any inspect entry you create produces output with unprintable characters
-they will be displayed in either the ^C notation or hexidecimal <FF> form,
+they will be displayed in either the ^C notation or hexadecimal <FF> form,
depending on their value.
This applies to tab characters as well, which will show as '^I'.
If you want a truer representation, any embedded tabs should be expanded.

View File

@ -0,0 +1,39 @@
From 9c776bbcde2260f454b51b86d46aafcc2f7dc71c Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 6 Nov 2013 00:00:00 -0600
Subject: [PATCH] top: expand on column highlight quirks in man document
Confession is supposed to be good for the sole, right?
After a senior moment regarding the 'x' toggle quirks,
and thinking top had somehow regressed, I concluded an
additional explanatory note might well be appropriate.
Those quirks were already documented under the 5d & 5e
topics. But there was no such caution documented under
the 'x' command explanation itself, found in topic 4c.
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.1 | 5 +++++
1 file changed, 5 insertions(+)
diff --git top/top.1 top/top.1
index 64a6a36..87659be 100644
--- top/top.1
+++ top/top.1
@@ -1270,6 +1270,11 @@ The sort field might\fI not\fR be visible because:
1) there is insufficient\fI Screen Width \fR
2) the 'f' \*(CI turned it \*F
+\*(NT Whenever 'Searching' and/or 'Other Filtering' is active in a window,
+column highlighting is temporarily disabled.
+\*(XC notes at the end of topics 5d. SEARCHING and 5e. FILTERING for an
+explanation why.
+
.TP 7
\ \ \ \fBy\fR\ \ :\fIRow-Highlight\fR toggle \fR
Changes highlighting for "running" tasks.
--
1.7.9.2

View File

@ -0,0 +1,60 @@
From bdb2fe005616bb40f2da53da02b01f91cabf9a87 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 7 Nov 2013 00:00:00 -0600
Subject: [PATCH] top: add some flexibility to dlopen() for numa support
A recent libnuma potential corruption problem solution
suggests that libnuma could change in the future so as
to not spew to stderr. This then raises a question how
top could exploit any such library change since we are
currently locked into version #1 of the library by way
of our dlopen("libnuma.so.1", RTLD_LAZY) runtime call.
While not an ultimate solution, this commit will first
try for the most recent version of that library during
top's startup before trying the original libnuma.so.1.
We do this via the unqualified library soname symlink.
For this new dlopen() call to succeed, technically the
numa 'devel' package would usually have been required,
but that's not always true with every distro. And when
the libnuma.so symlink isn't present, it can always be
manually added should a newer & better behaved library
arrive & users tire of the stderr warning at top exit.
Reference(s):
commit 24bd950cb2e1722d459461f0f9c0c30a4b9ffdaa
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git top/top.c top/top.c
index a48a5b9..e619ddd 100644
--- top/top.c
+++ top/top.c
@@ -3246,8 +3246,9 @@ static void before (char *me) {
#if defined(PRETEND_NUMA) || defined(PRETEND8CPUS)
Numa_node_tot = Numa_max_node() + 1;
#else
- Libnuma_handle = dlopen("libnuma.so.1", RTLD_LAZY);
- if (Libnuma_handle) {
+ // we'll try for the most recent version, then a version we know works...
+ if ((Libnuma_handle = dlopen("libnuma.so", RTLD_LAZY))
+ || (Libnuma_handle = dlopen("libnuma.so.1", RTLD_LAZY))) {
Numa_max_node = dlsym(Libnuma_handle, "numa_max_node");
Numa_node_of_cpu = dlsym(Libnuma_handle, "numa_node_of_cpu");
if (Numa_max_node && Numa_node_of_cpu)
@@ -3265,7 +3266,7 @@ static void before (char *me) {
#endif
// lastly, establish a robust signals environment
sigemptyset(&sa.sa_mask);
- // with user position perserved through SIGWINCH, we must avoid SA_RESTART
+ // with user position preserved through SIGWINCH, we must avoid SA_RESTART
sa.sa_flags = 0;
for (i = SIGRTMAX; i; i--) {
switch (i) {
--
1.7.9.2

View File

@ -0,0 +1,109 @@
From f12c0d5c6e84f9409ac3a73c066841a8ff5aab0b Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 8 Nov 2013 00:00:00 -0600
Subject: [PATCH] top: minimize the statistics overhead for numa support
A recent libnuma potential corruption problem solution
has caused me to reevaluate some associated numa logic
for efficiency. Here is a summary of the problems that
exist with current libnuma/user possible interactions:
. Whenever the numa library was present extra overhead
would always be incurred in maintaining the node stats
even when the '2' or '3' commands were not being used.
. As part of such overhead a separate loop was used to
reinitialize each cpu/node structure with each display
cycle so that prior accumulated totals were preserved.
Again, it didn't matter if numa data was really shown.
This commit attempts to refocus on the 'critical path'
costs in a running top by optimizing for the occasions
when numa node data is not being displayed. Under such
conditions, no extra overhead will be incurred whether
or not a distribution has the libnuma library present.
To achieve this goal, some additional overhead will be
incurred, but only when actually displaying numa data.
And all such new costs have been minimized in spite of
the gcc inclination to duplicate subscript resolution.
Reference(s):
commit 24bd950cb2e1722d459461f0f9c0c30a4b9ffdaa
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git top/top.c top/top.c
index e619ddd..9d12693 100644
--- top/top.c
+++ top/top.c
@@ -2361,18 +2361,9 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
#endif
#ifndef NUMA_DISABLE
- for (i = 0; i < Numa_node_tot; i++) {
- node = sumSLOT + 1 + i;
- // remember from last time around
- memcpy(&cpus[node].sav, &cpus[node].cur, sizeof(CT_t));
- // initialize current node statistics
- memset(&cpus[node].cur, 0, sizeof(CT_t));
-#ifndef CPU_ZEROTICS
- cpus[node].edge = cpus[sumSLOT].edge;
- // this is for symmetry only, it's not currently required
- cpus[node].cur.tot = cpus[sumSLOT].cur.tot;
-#endif
- }
+ // forget all of the prior node statistics (maybe)
+ if (CHKw(Curwin, View_CPUNOD))
+ memset(&cpus[sumSLOT + 1], 0, Numa_node_tot * sizeof(CPU_t));
#endif
// now value each separate cpu's tics...
@@ -2400,21 +2391,30 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
cpus[i].id = i;
#endif
#ifndef NUMA_DISABLE
- if (Numa_node_tot
+ /* henceforth, with just a little more arithmetic we can avoid
+ maintaining *any* node stats unless they're actually needed */
+ if (CHKw(Curwin, View_CPUNOD)
+ && Numa_node_tot
&& -1 < (node = Numa_node_of_cpu(cpus[i].id))) {
+ // use our own pointer to avoid gcc subscript bloat
+ CPU_t *nod_ptr = &cpus[sumSLOT + 1 + node];
+ nod_ptr->cur.u += cpus[i].cur.u; nod_ptr->sav.u += cpus[i].sav.u;
+ nod_ptr->cur.n += cpus[i].cur.n; nod_ptr->sav.n += cpus[i].sav.n;
+ nod_ptr->cur.s += cpus[i].cur.s; nod_ptr->sav.s += cpus[i].sav.s;
+ nod_ptr->cur.i += cpus[i].cur.i; nod_ptr->sav.i += cpus[i].sav.i;
+ nod_ptr->cur.w += cpus[i].cur.w; nod_ptr->sav.w += cpus[i].sav.w;
+ nod_ptr->cur.x += cpus[i].cur.x; nod_ptr->sav.x += cpus[i].sav.x;
+ nod_ptr->cur.y += cpus[i].cur.y; nod_ptr->sav.y += cpus[i].sav.y;
+ nod_ptr->cur.z += cpus[i].cur.z; nod_ptr->sav.z += cpus[i].sav.z;
+#ifndef CPU_ZEROTICS
+ /* yep, we re-value this repeatedly for each cpu encountered, but we
+ can then avoid a prior loop to selectively initialize each node */
+ nod_ptr->edge = cpus[sumSLOT].edge;
+#endif
cpus[i].node = node;
- node += (sumSLOT + 1);
- cpus[node].cur.u += cpus[i].cur.u;
- cpus[node].cur.n += cpus[i].cur.n;
- cpus[node].cur.s += cpus[i].cur.s;
- cpus[node].cur.i += cpus[i].cur.i;
- cpus[node].cur.w += cpus[i].cur.w;
- cpus[node].cur.x += cpus[i].cur.x;
- cpus[node].cur.y += cpus[i].cur.y;
- cpus[node].cur.z += cpus[i].cur.z;
}
#endif
- }
+ } // end: for each cpu
Cpu_faux_tot = i; // tolerate cpus taken offline
--
1.7.9.2

View File

@ -0,0 +1,149 @@
From 89c2f28e393830d899e3e91b60c830a6f07d38d5 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sat, 9 Nov 2013 00:00:00 -0600
Subject: [PATCH] top: eliminate yet more gcc subscript resolution bloat
This patch is inspired by the 'minimize numa overhead'
patch. It trades the use of subscripts for pointers to
avoid gcc repeated subscript offset calculation bloat.
Now, throughout the cpus_refresh function, a subscript
will be resolved just once & this will (dramatically?)
reduce the path-length taken for each and every frame!
For example, a non-optimized compilation could produce
400+ fewer machine instructions through pointer usage.
[ ok, optimized compiles only save 18+ instructions! ]
Lastly, any residual 'symmetry only' crap is now gone!
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 65 +++++++++++++++++++++++++++++++------------------------------
1 file changed, 33 insertions(+), 32 deletions(-)
diff --git top/top.c top/top.c
index 9d12693..151693d 100644
--- top/top.c
+++ top/top.c
@@ -2298,6 +2298,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
static FILE *fp = NULL;
static int siz, sav_slot = -1;
static char *buf;
+ CPU_t *sum_ptr; // avoid gcc subscript bloat
int i, num, tot_read;
#ifndef NUMA_DISABLE
int node;
@@ -2342,76 +2343,76 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
#undef buffGRW
// remember from last time around
- memcpy(&cpus[sumSLOT].sav, &cpus[sumSLOT].cur, sizeof(CT_t));
+ sum_ptr = &cpus[sumSLOT];
+ memcpy(&sum_ptr->sav, &sum_ptr->cur, sizeof(CT_t));
// then value the last slot with the cpu summary line
if (4 > sscanf(bp, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
- , &cpus[sumSLOT].cur.u, &cpus[sumSLOT].cur.n, &cpus[sumSLOT].cur.s
- , &cpus[sumSLOT].cur.i, &cpus[sumSLOT].cur.w, &cpus[sumSLOT].cur.x
- , &cpus[sumSLOT].cur.y, &cpus[sumSLOT].cur.z))
+ , &sum_ptr->cur.u, &sum_ptr->cur.n, &sum_ptr->cur.s
+ , &sum_ptr->cur.i, &sum_ptr->cur.w, &sum_ptr->cur.x
+ , &sum_ptr->cur.y, &sum_ptr->cur.z))
error_exit(N_txt(FAIL_statget_txt));
#ifndef CPU_ZEROTICS
- cpus[sumSLOT].cur.tot = cpus[sumSLOT].cur.u + cpus[sumSLOT].cur.s
- + cpus[sumSLOT].cur.n + cpus[sumSLOT].cur.i + cpus[sumSLOT].cur.w
- + cpus[sumSLOT].cur.x + cpus[sumSLOT].cur.y + cpus[sumSLOT].cur.z;
+ sum_ptr->cur.tot = sum_ptr->cur.u + sum_ptr->cur.s
+ + sum_ptr->cur.n + sum_ptr->cur.i + sum_ptr->cur.w
+ + sum_ptr->cur.x + sum_ptr->cur.y + sum_ptr->cur.z;
/* if a cpu has registered substantially fewer tics than those expected,
we'll force it to be treated as 'idle' so as not to present misleading
percentages. */
- cpus[sumSLOT].edge =
- ((cpus[sumSLOT].cur.tot - cpus[sumSLOT].sav.tot) / smp_num_cpus()) / (100 / TICS_EDGE);
+ sum_ptr->edge =
+ ((sum_ptr->cur.tot - sum_ptr->sav.tot) / smp_num_cpus()) / (100 / TICS_EDGE);
#endif
#ifndef NUMA_DISABLE
// forget all of the prior node statistics (maybe)
if (CHKw(Curwin, View_CPUNOD))
- memset(&cpus[sumSLOT + 1], 0, Numa_node_tot * sizeof(CPU_t));
+ memset(sum_ptr + 1, 0, Numa_node_tot * sizeof(CPU_t));
#endif
// now value each separate cpu's tics...
for (i = 0; i < sumSLOT; i++) {
+ CPU_t *cpu_ptr = &cpus[i]; // avoid gcc subscript bloat
#ifdef PRETEND8CPUS
bp = buf;
#endif
bp = 1 + strchr(bp, '\n');
// remember from last time around
- memcpy(&cpus[i].sav, &cpus[i].cur, sizeof(CT_t));
- if (4 > sscanf(bp, "cpu%d %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &cpus[i].id
- , &cpus[i].cur.u, &cpus[i].cur.n, &cpus[i].cur.s
- , &cpus[i].cur.i, &cpus[i].cur.w, &cpus[i].cur.x
- , &cpus[i].cur.y, &cpus[i].cur.z)) {
- memmove(&cpus[i], &cpus[sumSLOT], sizeof(CPU_t));
+ memcpy(&cpu_ptr->sav, &cpu_ptr->cur, sizeof(CT_t));
+ if (4 > sscanf(bp, "cpu%d %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &cpu_ptr->id
+ , &cpu_ptr->cur.u, &cpu_ptr->cur.n, &cpu_ptr->cur.s
+ , &cpu_ptr->cur.i, &cpu_ptr->cur.w, &cpu_ptr->cur.x
+ , &cpu_ptr->cur.y, &cpu_ptr->cur.z)) {
+ memmove(cpu_ptr, sum_ptr, sizeof(CPU_t));
break; // tolerate cpus taken offline
}
#ifndef CPU_ZEROTICS
- cpus[i].edge = cpus[sumSLOT].edge;
- // this is for symmetry only, it's not currently required
- cpus[i].cur.tot = cpus[sumSLOT].cur.tot;
+ cpu_ptr->edge = sum_ptr->edge;
#endif
#ifdef PRETEND8CPUS
- cpus[i].id = i;
+ cpu_ptr->id = i;
#endif
#ifndef NUMA_DISABLE
/* henceforth, with just a little more arithmetic we can avoid
maintaining *any* node stats unless they're actually needed */
if (CHKw(Curwin, View_CPUNOD)
&& Numa_node_tot
- && -1 < (node = Numa_node_of_cpu(cpus[i].id))) {
+ && -1 < (node = Numa_node_of_cpu(cpu_ptr->id))) {
// use our own pointer to avoid gcc subscript bloat
- CPU_t *nod_ptr = &cpus[sumSLOT + 1 + node];
- nod_ptr->cur.u += cpus[i].cur.u; nod_ptr->sav.u += cpus[i].sav.u;
- nod_ptr->cur.n += cpus[i].cur.n; nod_ptr->sav.n += cpus[i].sav.n;
- nod_ptr->cur.s += cpus[i].cur.s; nod_ptr->sav.s += cpus[i].sav.s;
- nod_ptr->cur.i += cpus[i].cur.i; nod_ptr->sav.i += cpus[i].sav.i;
- nod_ptr->cur.w += cpus[i].cur.w; nod_ptr->sav.w += cpus[i].sav.w;
- nod_ptr->cur.x += cpus[i].cur.x; nod_ptr->sav.x += cpus[i].sav.x;
- nod_ptr->cur.y += cpus[i].cur.y; nod_ptr->sav.y += cpus[i].sav.y;
- nod_ptr->cur.z += cpus[i].cur.z; nod_ptr->sav.z += cpus[i].sav.z;
+ CPU_t *nod_ptr = sum_ptr + 1 + node;
+ nod_ptr->cur.u += cpu_ptr->cur.u; nod_ptr->sav.u += cpu_ptr->sav.u;
+ nod_ptr->cur.n += cpu_ptr->cur.n; nod_ptr->sav.n += cpu_ptr->sav.n;
+ nod_ptr->cur.s += cpu_ptr->cur.s; nod_ptr->sav.s += cpu_ptr->sav.s;
+ nod_ptr->cur.i += cpu_ptr->cur.i; nod_ptr->sav.i += cpu_ptr->sav.i;
+ nod_ptr->cur.w += cpu_ptr->cur.w; nod_ptr->sav.w += cpu_ptr->sav.w;
+ nod_ptr->cur.x += cpu_ptr->cur.x; nod_ptr->sav.x += cpu_ptr->sav.x;
+ nod_ptr->cur.y += cpu_ptr->cur.y; nod_ptr->sav.y += cpu_ptr->sav.y;
+ nod_ptr->cur.z += cpu_ptr->cur.z; nod_ptr->sav.z += cpu_ptr->sav.z;
#ifndef CPU_ZEROTICS
/* yep, we re-value this repeatedly for each cpu encountered, but we
can then avoid a prior loop to selectively initialize each node */
- nod_ptr->edge = cpus[sumSLOT].edge;
+ nod_ptr->edge = sum_ptr->edge;
#endif
- cpus[i].node = node;
+ cpu_ptr->node = node;
}
#endif
} // end: for each cpu
--
1.7.9.2

View File

@ -0,0 +1,63 @@
Based on 57ab5eed15a577fda6ce24753948ab29f30de2d4 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 29 Nov 2013 00:00:00 -0600
Subject: [PATCH] top: do not lie about purported alphabetical orderings
Excluding those special X_XON/X_XOF enums, which might
not even be present, restore strict collating order of
all the case labels in the task_show switch statement.
Also, adjust a few sort callbacks for the same reason.
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git top/top.c top/top.c
index 70eaa4a..59dcb3f 100644
--- top/top.c
+++ top/top.c
@@ -246,9 +246,9 @@ SCB_NUM1(CPU, pcpu)
SCB_NUM1(DAT, drs)
SCB_NUM1(DRT, dt)
SCB_STRS(ENV, environ[0])
-SCB_NUM1(FLG, flags)
SCB_NUM1(FL1, maj_flt)
SCB_NUM1(FL2, min_flt)
+SCB_NUM1(FLG, flags)
SCB_NUM1(FV1, maj_delta)
SCB_NUM1(FV2, min_delta)
SCB_NUMx(GID, egid)
@@ -5220,15 +5220,15 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
case P_ENV:
makeVAR(p->environ[0]);
break;
- case P_FLG:
- cp = make_str(hex_make(p->flags, 1), W, Js, AUTOX_NO);
- break;
case P_FL1:
cp = scale_num(p->maj_flt, W, Jn);
break;
case P_FL2:
cp = scale_num(p->min_flt, W, Jn);
break;
+ case P_FLG:
+ cp = make_str(hex_make(p->flags, 1), W, Js, AUTOX_NO);
+ break;
case P_FV1:
cp = scale_num(p->maj_delta, W, Jn);
break;
@@ -5308,8 +5308,8 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
case P_THD:
cp = make_num(p->nlwp, W, Jn, AUTOX_NO);
break;
- case P_TME:
case P_TM2:
+ case P_TME:
{ TIC_t t = p->utime + p->stime;
if (CHKw(q, Show_CTIMES)) t += (p->cutime + p->cstime);
cp = scale_tics(t, W, Jn);
--
1.7.9.2

View File

@ -0,0 +1,60 @@
From 4c464acf283b83f052af075f1190f146550c77a5 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sat, 30 Nov 2013 00:00:00 -0600
Subject: [PATCH] top: follow usual name conventions for global variable
A recent change involving a one cycle stderr redirect,
to handle a libnuma potential transgression, failed to
follow normal global variable naming conventions. This
patch will capitalize the 1st letter of 'Stderr_save'.
Reference(s):
commit 35dc6dcc49cc9cf8cff4300cb03a38dbe44c05db
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git top/top.c top/top.c
index 59dcb3f..4d1d912 100644
--- top/top.c
+++ top/top.c
@@ -220,7 +220,7 @@ static int Numa_node_tot;
static int Numa_node_sel = -1;
#ifndef NUMA_DISABLE
static void *Libnuma_handle;
-static int stderr_save = -1;
+static int Stderr_save = -1;
#if defined(PRETEND_NUMA) || defined(PRETEND8CPUS)
static int Numa_max_node(void) { return 3; }
static int Numa_node_of_cpu(int num) { return (num % 4); }
@@ -4069,8 +4069,8 @@ static void wins_stage_2 (void) {
Yes, he provides some overridable 'weak' functions to change such
behavior but we can't exploit that since we don't follow a normal
ld route to symbol resolution (we use that dlopen() guy instead)! */
- stderr_save = dup(fileno(stderr));
- if (-1 < stderr_save && freopen("/dev/null", "w", stderr))
+ Stderr_save = dup(fileno(stderr));
+ if (-1 < Stderr_save && freopen("/dev/null", "w", stderr))
; // avoid -Wunused-result
#endif
@@ -5553,10 +5553,10 @@ static void frame_make (void) {
#ifndef NUMA_DISABLE
/* we gotta reverse the stderr redirect which was employed in wins_stage_2
and needed because the two libnuma 'weak' functions were useless to us! */
- if (-1 < stderr_save) {
- dup2(stderr_save, fileno(stderr));
- close(stderr_save);
- stderr_save = -1;
+ if (-1 < Stderr_save) {
+ dup2(Stderr_save, fileno(stderr));
+ close(Stderr_save);
+ Stderr_save = -1;
}
#endif
--
1.7.9.2

View File

@ -0,0 +1,139 @@
From b6fcb602ce0f80e818004340e6ddb5a788bb832d Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sun, 5 Jan 2014 00:00:00 -0600
Subject: [PATCH] top: provide for discontinuous (not active) NUMA nodes
Apparently there are occasions when NUMA nodes may not
always be contiguous. Under such conditions nodes that
were not used would still occupy precious Summary Area
space showing 100% idle, under the '2' command toggle.
With this commit top will no longer display numa nodes
that have no associated cpu when the '2' toggle is on.
But just in case we wish to return to former behavior,
a new #define called OFF_NUMASKIP has been introduced.
And as an aside, a recent refactor mentioned below set
the stage for this patch to be 'self-tuning'. In other
words, if an inactive/non-displayed node should become
active (if even possible), then top will begin showing
such a node automatically with the next screen update.
Unfortunately, all inactive nodes now 'suppressed' are
still accessible via the '3' command. Those nodes will
just be displayed as empty (no associated cpus shown).
This is not really a top problem but more of a libnuma
and/or user deficiency. The library lacks the means to
validate a node id and the user then input a node that
was not even shown under a '2' toggle Summary display.
( too bad libnuma does not offer an 'is_node_active' )
( type function so top could warn a user when such a )
( discontinuous node was requested using his '3' cmd )
( sure, top could achieve this objective himself but )
( that would require making yet another array global )
( which i'm just not in the mood to do - besides, we )
( have already made enough concessions to libnuma.so )
Lastly, an existing #define (PRETEND_NUMA) was changed
to 'disable' node #1 so as to simulate a discontinuous
node. This allows testing of the '2' and '3' commands.
Reference(s):
http://www.spinics.net/lists/util-linux-ng/msg08671.html
. set stage for self tuning
commit f12c0d5c6e84f9409ac3a73c066841a8ff5aab0b
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 16 +++++++++++++++-
top/top.h | 8 ++++++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git top/top.c top/top.c
index bb15d01..cb1a063 100644
--- top/top.c
+++ top/top.c
@@ -223,7 +223,11 @@ static void *Libnuma_handle;
static int Stderr_save = -1;
#if defined(PRETEND_NUMA) || defined(PRETEND8CPUS)
static int Numa_max_node(void) { return 3; }
+#ifndef OFF_NUMASKIP
+static int Numa_node_of_cpu(int num) { return (1 == (num % 4)) ? 0 : (num % 4); }
+#else
static int Numa_node_of_cpu(int num) { return (num % 4); }
+#endif
#else
static int (*Numa_max_node)(void);
static int (*Numa_node_of_cpu)(int num);
@@ -2430,6 +2434,9 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
nod_ptr->edge = sum_ptr->edge;
#endif
cpu_ptr->node = node;
+#ifndef OFF_NUMASKIP
+ nod_ptr->id = -1;
+#endif
}
#endif
} // end: for each cpu
@@ -5056,10 +5063,17 @@ static void summary_show (void) {
Msg_row += 1;
// display each cpu node's states
for (i = 0; i < Numa_node_tot; i++) {
+ CPU_t *nod_ptr = &smpcpu[1 + smp_num_cpus() + i];
if (!isROOM(anyFLG, 1)) break;
+#ifndef OFF_NUMASKIP
+ if (nod_ptr->id) {
+#endif
snprintf(tmp, sizeof(tmp), N_fmt(NUMA_nodenam_fmt), i);
- summary_hlp(&smpcpu[1 + smp_num_cpus() + i], tmp);
+ summary_hlp(nod_ptr, tmp);
Msg_row += 1;
+#ifndef OFF_NUMASKIP
+ }
+#endif
}
} else {
// display the node summary, then the associated cpus (if room)
diff --git top/top.h top/top.h
index 16f7668..8e83b61 100644
--- top/top.h
+++ top/top.h
@@ -41,12 +41,13 @@
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
+//#define OFF_NUMASKIP /* do NOT skip numa nodes if discontinuous */
//#define OFF_SCROLLBK /* disable tty emulators scrollback buffer */
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
//#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */
//#define PRETEND8CPUS /* pretend we're smp with 8 ticsers (sic) */
//#define PRETENDNOCAP /* use a terminal without essential caps */
-//#define PRETEND_NUMA /* pretend we've got some linux NUMA Nodes */
+//#define PRETEND_NUMA /* pretend 4 (or 3 w/o OFF_NUMASKIP) Nodes */
//#define RCFILE_NOERR /* rcfile errs silently default, vs. fatal */
//#define RECALL_FIXED /* don't reorder saved strings if recalled */
//#define RMAN_IGNORED /* don't consider auto right margin glitch */
@@ -277,7 +278,7 @@ typedef struct CPU_t {
#ifndef CPU_ZEROTICS
SIC_t edge; // tics adjustment threshold boundary
#endif
- int id; // the cpu id number (0 - nn)
+ int id; // cpu number (0 - nn), or numa active flag
#ifndef NUMA_DISABLE
int node; // the numa node it belongs to
#endif
@@ -628,6 +629,9 @@ typedef struct WIN_t {
#if defined(PRETEND_NUMA) && defined(NUMA_DISABLE)
# error 'PRETEND_NUMA' confilcts with 'NUMA_DISABLE'
#endif
+#if defined(OFF_NUMASKIP) && defined(NUMA_DISABLE)
+# error 'OFF_NUMASKIP' confilcts with 'NUMA_DISABLE'
+#endif
#if (LRGBUFSIZ < SCREENMAX)
# error 'LRGBUFSIZ' must NOT be less than 'SCREENMAX'
#endif
--
1.7.9.2

View File

@ -0,0 +1,124 @@
From bcf4f5a830ad008e0bd9341105db825a22ea3906 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 20 Feb 2014 00:00:00 -0600
Subject: [PATCH] top: restore the former behavior after stderr redirect
When top originally responded to the potential libnuma
stderr write, the library was consistently called with
each refresh cycle. That, in turn, guaranteed that any
warning message would be seen at program end by virtue
of: 1) having been issued before the 2nd refresh cycle
and; 2) benefiting from inherited /dev/null buffering.
A later efficiency refactor meant the numa library may
not always be called with every refresh cycle. Rather,
it was only called if top was in one of two numa views
(the '2' or '3' toggles). That, in turn, resulted in a
loss of any warning message at program end unless numa
mode had been preserved in the rcfile. In other words,
if top was started normally then a single cycle stderr
redirect would have long passed by the time the '2' or
'3' toggle was activated. The warning message actually
was spewed but quickly lost to the full screen refresh
which follows all keyboard interactions with the user.
This commit simply moves the restoration of our stderr
redirect to program end (instead of that first display
refresh). Now, any libnuma stderr warning message will
appear as the concluding output line upon quitting top
without regard to when any numa mode view was invoked.
And since this technique might be useful in some other
context (as an example of how to 'buffer' stderr) it's
been generalized with its own #define. But to maximize
its usefulness, the original redirect should be issued
much earlier in pgm startup than top has chosen to do.
Reference(s):
. original libnuma stderr response (msg seen)
commit 35dc6dcc49cc9cf8cff4300cb03a38dbe44c05db
. numa refractoring for efficiency (msg lost)
commit f12c0d5c6e84f9409ac3a73c066841a8ff5aab0b
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 25 +++++++++++++------------
top/top.h | 1 +
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git top/top.c top/top.c
index cb1a063..23dad92 100644
--- top/top.c
+++ top/top.c
@@ -216,11 +216,13 @@ static int Autox_array [P_MAXPFLGS],
/* Support for NUMA Node display, node expansion/targeting and
run-time dynamic linking with libnuma.so treated as a plugin */
+#ifndef OFF_STDERROR
+static int Stderr_save = -1;
+#endif
static int Numa_node_tot;
static int Numa_node_sel = -1;
#ifndef NUMA_DISABLE
static void *Libnuma_handle;
-static int Stderr_save = -1;
#if defined(PRETEND_NUMA) || defined(PRETEND8CPUS)
static int Numa_max_node(void) { return 3; }
#ifndef OFF_NUMASKIP
@@ -377,6 +379,15 @@ static void at_eoj (void) {
#endif
}
fflush(stdout);
+#ifndef OFF_STDERROR
+ /* we gotta reverse the stderr redirect which was employed during start up
+ and needed because the two libnuma 'weak' functions were useless to us! */
+ if (-1 < Stderr_save) {
+ dup2(Stderr_save, fileno(stderr));
+ close(Stderr_save);
+ Stderr_save = -1; // we'll be ending soon anyway but what the heck
+ }
+#endif
} // end: at_eoj
@@ -4070,7 +4081,7 @@ static void wins_stage_2 (void) {
// fill in missing Fieldstab members and build each window's columnhdr
zap_fieldstab();
-#ifndef NUMA_DISABLE
+#ifndef OFF_STDERROR
/* there's a chance that damn libnuma may spew to stderr so we gotta
make sure he does not corrupt poor ol' top's first output screen!
Yes, he provides some overridable 'weak' functions to change such
@@ -5564,16 +5575,6 @@ static void frame_make (void) {
the normal non-interactive output optimization... */
if (!Cap_can_goto) PSU_CLREOS(0);
-#ifndef NUMA_DISABLE
- /* we gotta reverse the stderr redirect which was employed in wins_stage_2
- and needed because the two libnuma 'weak' functions were useless to us! */
- if (-1 < Stderr_save) {
- dup2(Stderr_save, fileno(stderr));
- close(Stderr_save);
- Stderr_save = -1;
- }
-#endif
-
/* lastly, check auto-sized width needs for the next iteration */
if (AUTOX_MODE && Autox_found)
widths_resize();
diff --git top/top.h top/top.h
index 8e83b61..862568c 100644
--- top/top.h
+++ top/top.h
@@ -43,6 +43,7 @@
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
//#define OFF_NUMASKIP /* do NOT skip numa nodes if discontinuous */
//#define OFF_SCROLLBK /* disable tty emulators scrollback buffer */
+//#define OFF_STDERROR /* disable our stderr buffering (redirect) */
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
//#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */
//#define PRETEND8CPUS /* pretend we're smp with 8 ticsers (sic) */
--
1.7.9.2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
Based on 22e658297494e11ef92a81069b49a40420b8d824 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 25 Apr 2014 00:00:00 -0500
Subject: [PATCH] top: protect against distortion when system time reset
If a system's time is adjusted backwards, then elapsed
time could appear as negative. This yielded a negative
%CPU value. Alternately if zeros were suppressed ('0')
the result was a blank %CPU column. In both cases that
distortion would last for one display cycle or until a
user forced a display refresh via some keyboard input.
The original recommendation was trading gettimeofday()
for clock_gettime() using CLOCK_MONOTONIC. But on some
systems that might not be possible, forcing the use of
CLOCK_REALTIME instead. Not only would that complicate
the build system, but it may leave us with minus %CPU.
Another approach was to ensure that elapsed time could
never be negative. Of course, this produced distortion
of %CPU values but it would be proportionally correct.
This wasn't dissimilar to a distortion already present
should the time be adjusted forward or backward within
any 'remaining' top delay intervals. These aberrations
would be avoided with clock_gettime & CLOCK_MONOTONIC,
but that is a less than ideal solution as noted above.
This final solution, which originated down under, will
simply rely on the /proc/uptime seconds, which will be
immune to *any* tampering with the system clock. Thus,
we now have a fix for the distortion we didn't know we
suffered plus a negative %CPU that began this odyssey.
Thanks to:
sk.alvin.x@gmail.com, for the original effort
jcapik@redhat.com, for a heads up on CLOCK_MONOTONIC
csmall-procps@enc.com.au, for the best suggestion of all
Reference(s):
. original post/patch
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday
. heads up on CLOCK_MONOTONIC
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday,2
. the final solution
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday,11
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
--- top/top.c
+++ top/top.c 2014-05-15 00:00:00.000000000 +0000
@@ -2514,17 +2514,14 @@ static void procs_hlp (proc_t *this) {
HST_t *h;
if (!this) {
- static struct timeval oldtimev;
- struct timeval timev;
- struct timezone timez;
+ static double uptime_sav;
+ double uptime_cur;
float et;
void *v;
- gettimeofday(&timev, &timez);
- et = (timev.tv_sec - oldtimev.tv_sec)
- + (float)(timev.tv_usec - oldtimev.tv_usec) / 1000000.0;
- oldtimev.tv_sec = timev.tv_sec;
- oldtimev.tv_usec = timev.tv_usec;
+ uptime(&uptime_cur, NULL);
+ et = uptime_cur - uptime_sav;
+ uptime_sav = uptime_cur;
// if in Solaris mode, adjust our scaling for all cpus
Frame_etscale = 100.0f / ((float)Hertz * (float)et * (Rc.mode_irixps ? 1 : smp_num_cpus()));

View File

@ -0,0 +1,32 @@
From fe37ad15cd394af021af7a3e5ad11bad70af4bfd Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sun, 27 Apr 2014 00:00:00 -0500
Subject: [PATCH] top: avoid a 'nan' when the delay interval is very low
The granularity of /proc/uptime is fixed at hundredths
of a second. And, since we can cycle faster than that,
we are exposed to 'nan' when calculating elapsed time.
This commit will protect us from that outcome when the
delay interval has been set to an extremely low value.
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 1 +
1 file changed, 1 insertion(+)
diff --git top/top.c top/top.c
index 0428496..0ae5388 100644
--- top/top.c
+++ top/top.c
@@ -2525,6 +2525,7 @@ static void procs_hlp (proc_t *this) {
uptime(&uptime_cur, NULL);
et = uptime_cur - uptime_sav;
+ if (et < 0.01) et = 0.005;
uptime_sav = uptime_cur;
// if in Solaris mode, adjust our scaling for all cpus
--
1.7.9.2

View File

@ -0,0 +1,287 @@
From bef6b0f025a0638c37bf987039b65272f0fff587 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Sun, 27 Apr 2014 00:00:00 -0500
Subject: [PATCH] top: standardize <Esc> key support with prompted input
In release 3.3.6, some commands were equipped with the
concept of a 'default pid'. The initial implementation
meant that the intuitive <Esc> key would not always be
treated as one would expect under any well behaved UI.
This patch ensures the expected <Esc> key behavior of:
terminating user input while still making possible the
necessary distinction between 'no input' & 'defaults'.
Reference(s):
http://www.freelists.org/post/procps/top-Escape-doesnt-abort-kill-command
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.1 | 2 ++
top/top.c | 105 ++++++++++++++++++++++++++++++++++++-------------------------
2 files changed, 65 insertions(+), 42 deletions(-)
diff --git top/top.1 top/top.1
index c15a871..67b8b35 100644
--- top/top.1
+++ top/top.1
@@ -1082,6 +1082,7 @@ depending on your progress:
.nf
1) at the pid prompt, type an invalid number
2) at the signal prompt, type 0 (or any invalid signal)
+ 3) at any prompt, type <Esc>
.fi
.TP 7
@@ -1106,6 +1107,7 @@ depending on your progress:
.nf
1) at the pid prompt, type an invalid number
2) at the nice prompt, type <Enter> with no input
+ 3) at any prompt, type <Esc>
.fi
.TP 7
diff --git top/top.c top/top.c
index 0ae5388..9f33a05 100644
--- top/top.c
+++ top/top.c
@@ -1150,8 +1150,11 @@ static char *ioline (const char *prompt) {
key = iokey(2);
switch (key) {
case 0:
+ buf[0] = '\0';
+ return buf;
case kbd_ESC:
- buf[0] = '\0'; // fall through !
+ buf[0] = kbd_ESC;
+ return buf;
case kbd_ENTER:
continue;
case kbd_INS:
@@ -1197,7 +1200,7 @@ static char *ioline (const char *prompt) {
}
putp(fmtmk("%s%s%s", tg2(beg, Msg_row), Cap_clr_eol, buf));
putp(tg2(beg+pos, Msg_row));
- } while (key && key != kbd_ENTER && key != kbd_ESC);
+ } while (key != kbd_ENTER);
// weed out duplicates, including empty strings (top-of-stack)...
for (i = 0, plin = anchor; ; i++) {
@@ -1275,6 +1278,10 @@ static int readfile (FILE *fp, char **baddr, size_t *bsize, size_t *bread) {
/*###### Small Utility routines ########################################*/
+#define GET_NUM_BAD INT_MIN
+#define GET_NUM_ESC (INT_MIN + 1)
+#define GET_NUM_NOT (INT_MIN + 2)
+
/*
* Get a float from the user */
static float get_float (const char *prompt) {
@@ -1282,20 +1289,18 @@ static float get_float (const char *prompt) {
float f;
line = ioline(prompt);
- if (!line[0] || Frames_signal) return -1.0;
+ if (line[0] == kbd_ESC || Frames_signal) return GET_NUM_ESC;
+ if (!line[0]) return GET_NUM_NOT;
// note: we're not allowing negative floats
if (strcspn(line, "+,.0123456789")) {
show_msg(N_txt(BAD_numfloat_txt));
- return -1.0;
+ return GET_NUM_BAD;
}
sscanf(line, "%f", &f);
return f;
} // end: get_float
-#define GET_INT_BAD INT_MIN
-#define GET_INTNONE (INT_MIN + 1)
-
/*
* Get an integer from the user, returning INT_MIN for error */
static int get_int (const char *prompt) {
@@ -1303,12 +1308,12 @@ static int get_int (const char *prompt) {
int n;
line = ioline(prompt);
- if (Frames_signal) return GET_INT_BAD;
- if (!line[0]) return GET_INTNONE;
+ if (line[0] == kbd_ESC || Frames_signal) return GET_NUM_ESC;
+ if (!line[0]) return GET_NUM_NOT;
// note: we've got to allow negative ints (renice)
if (strcspn(line, "-+0123456789")) {
show_msg(N_txt(BAD_integers_txt));
- return GET_INT_BAD;
+ return GET_NUM_BAD;
}
sscanf(line, "%d", &n);
return n;
@@ -2918,7 +2923,9 @@ static void insp_find_str (int ch, int *col, int *row) {
return;
}
if (ch == 'L' || ch == '/') {
- snprintf(Insp_sel->fstr, FNDBUFSIZ, "%s", ioline(N_txt(GET_find_str_txt)));
+ char *str = ioline(N_txt(GET_find_str_txt));
+ if (*str == kbd_ESC) return;
+ snprintf(Insp_sel->fstr, FNDBUFSIZ, "%s", str);
Insp_sel->flen = strlen(Insp_sel->fstr);
found = 0;
}
@@ -4135,7 +4142,9 @@ static void find_string (int ch) {
return;
}
if ('L' == ch) {
- snprintf(Curwin->findstr, FNDBUFSIZ, "%s", ioline(N_txt(GET_find_str_txt)));
+ char *str = ioline(N_txt(GET_find_str_txt));
+ if (*str == kbd_ESC) return;
+ snprintf(Curwin->findstr, FNDBUFSIZ, "%s", str);
Curwin->findlen = strlen(Curwin->findstr);
found = 0;
#ifndef USE_X_COLHDR
@@ -4225,7 +4234,9 @@ static void other_selection (int ch) {
sel = strstr;
}
glob = ioline(fmtmk(N_fmt(OSEL_prompts_fmt), Curwin->osel_tot + 1, typ));
- if (!snprintf(raw, sizeof(raw), "%s", glob)) return;
+ if (*glob == kbd_ESC
+ || !snprintf(raw, sizeof(raw), "%s", glob))
+ return;
for (osel = Curwin->osel_1st; osel; ) {
if (!strcmp(osel->raw, glob)) { // #1: is criteria duplicate?
show_msg(N_txt(OSEL_errdups_txt));
@@ -4343,7 +4354,7 @@ static void keys_global (int ch) {
else {
float tmp =
get_float(fmtmk(N_fmt(DELAY_change_fmt), Rc.delay_time));
- if (-1 < tmp) Rc.delay_time = tmp;
+ if (tmp > -1) Rc.delay_time = tmp;
}
break;
case 'E':
@@ -4379,17 +4390,21 @@ static void keys_global (int ch) {
if (Secure_mode) {
show_msg(N_txt(NOT_onsecure_txt));
} else {
- int pid, sig = SIGTERM, def = w->ppt[w->begtask]->tid;
- if (GET_INT_BAD < (pid = get_int(fmtmk(N_txt(GET_pid2kill_fmt), def)))) {
+ int sig = SIGTERM,
+ def = w->ppt[w->begtask]->tid,
+ pid = get_int(fmtmk(N_txt(GET_pid2kill_fmt), def));
+ if (pid > GET_NUM_ESC) {
char *str;
- if (0 > pid) pid = def;
+ if (pid == GET_NUM_NOT) pid = def;
str = ioline(fmtmk(N_fmt(GET_sigs_num_fmt), pid, SIGTERM));
- if (*str) sig = signal_name_to_number(str);
- if (Frames_signal) break;
- if (0 < sig && kill(pid, sig))
- show_msg(fmtmk(N_fmt(FAIL_signals_fmt)
- , pid, sig, strerror(errno)));
- else if (0 > sig) show_msg(N_txt(BAD_signalid_txt));
+ if (*str != kbd_ESC) {
+ if (*str) sig = signal_name_to_number(str);
+ if (Frames_signal) break;
+ if (0 < sig && kill(pid, sig))
+ show_msg(fmtmk(N_fmt(FAIL_signals_fmt)
+ , pid, sig, strerror(errno)));
+ else if (0 > sig) show_msg(N_txt(BAD_signalid_txt));
+ }
}
}
break;
@@ -4397,21 +4412,24 @@ static void keys_global (int ch) {
if (Secure_mode)
show_msg(N_txt(NOT_onsecure_txt));
else {
- int val, pid, def = w->ppt[w->begtask]->tid;
- if (GET_INT_BAD < (pid = get_int(fmtmk(N_txt(GET_pid2nice_fmt), def)))) {
- if (0 > pid) pid = def;
- if (GET_INTNONE < (val = get_int(fmtmk(N_fmt(GET_nice_num_fmt), pid))))
- if (setpriority(PRIO_PROCESS, (unsigned)pid, val))
- show_msg(fmtmk(N_fmt(FAIL_re_nice_fmt)
- , pid, val, strerror(errno)));
+ int val,
+ def = w->ppt[w->begtask]->tid,
+ pid = get_int(fmtmk(N_txt(GET_pid2nice_fmt), def));
+ if (pid > GET_NUM_ESC) {
+ if (pid == GET_NUM_NOT) pid = def;
+ val = get_int(fmtmk(N_fmt(GET_nice_num_fmt), pid));
+ if (val > GET_NUM_NOT
+ && setpriority(PRIO_PROCESS, (unsigned)pid, val))
+ show_msg(fmtmk(N_fmt(FAIL_re_nice_fmt)
+ , pid, val, strerror(errno)));
}
}
break;
case 'X':
{ int wide = get_int(fmtmk(N_fmt(XTRA_fixwide_fmt), Rc.fixed_widest));
- if (GET_INTNONE < wide) {
- if (-1 < wide) Rc.fixed_widest = wide;
- else if (INT_MIN < wide) Rc.fixed_widest = -1;
+ if (wide > GET_NUM_NOT) {
+ if (wide > -1) Rc.fixed_widest = wide;
+ else Rc.fixed_widest = -1;
}
}
break;
@@ -4419,9 +4437,10 @@ static void keys_global (int ch) {
if (!Inspect.total)
ioline(N_txt(YINSP_noents_txt));
else {
- int pid, def = w->ppt[w->begtask]->tid;
- if (GET_INT_BAD < (pid = get_int(fmtmk(N_fmt(YINSP_pidsee_fmt), def)))) {
- if (0 > pid) pid = def;
+ int def = w->ppt[w->begtask]->tid,
+ pid = get_int(fmtmk(N_fmt(YINSP_pidsee_fmt), def));
+ if (pid > GET_NUM_ESC) {
+ if (pid == GET_NUM_NOT) pid = def;
if (pid) inspection_utility(pid);
}
}
@@ -4467,7 +4486,7 @@ static void keys_summary (int ch) {
show_msg(N_txt(NUMA_nodenot_txt));
else {
int num = get_int(fmtmk(N_fmt(NUMA_nodeget_fmt), Numa_node_tot -1));
- if (GET_INTNONE < num) {
+ if (num > GET_NUM_NOT) {
if (num >= 0 && num < Numa_node_tot) {
Numa_node_sel = num;
SETw(w, View_CPUNOD | View_STATES);
@@ -4503,7 +4522,7 @@ static void keys_task (int ch) {
case 'n':
if (VIZCHKw(w)) {
int num = get_int(fmtmk(N_fmt(GET_max_task_fmt), w->rc.maxtasks));
- if (GET_INTNONE < num) {
+ if (num > GET_NUM_NOT) {
if (-1 < num ) w->rc.maxtasks = num;
else show_msg(N_txt(BAD_max_task_txt));
}
@@ -4601,9 +4620,11 @@ static void keys_task (int ch) {
case 'U':
case 'u':
if (VIZCHKw(w)) {
- const char *errmsg;
- if ((errmsg = user_certify(w, ioline(N_txt(GET_user_ids_txt)), ch)))
- show_msg(errmsg);
+ const char *errmsg, *str = ioline(N_txt(GET_user_ids_txt));
+ if (*str != kbd_ESC
+ && (errmsg = user_certify(w, str, ch)))
+ show_msg(errmsg);
+
}
break;
case 'V':
@@ -4686,7 +4707,7 @@ static void keys_window (int ch) {
if (ALTCHKw) {
char tmp[SMLBUFSIZ];
STRLCPY(tmp, ioline(fmtmk(N_fmt(NAME_windows_fmt), w->rc.winname)));
- if (tmp[0]) win_names(w, tmp);
+ if (tmp[0] && tmp[0] != kbd_ESC) win_names(w, tmp);
}
break;
case kbd_UP:
--
1.7.9.2

View File

@ -0,0 +1,33 @@
Based on 0caa6d6e676c8d28b933066d19c112b02ed59245 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 7 May 2014 00:00:00 -0500
Subject: [PATCH] top: miscellaneous accumulated changes to program code
. prevent any input recall overrun if window downsized
. adjust translation notes for true column hdr maximum
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
top/top.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git top/top.c top/top.c
index 9f33a05..bc755f3 100644
--- top/top.c
+++ top/top.c
@@ -1183,13 +1183,13 @@ static char *ioline (const char *prompt) {
if (plin->bkw) {
plin = plin->bkw;
memset(buf, '\0', sizeof(buf));
- pos = snprintf(buf, sizeof(buf), "%s", plin->str);
+ pos = snprintf(buf, sizeof(buf), "%.*s", Screen_cols - beg - 1, plin->str);
}
break;
case kbd_DOWN:
memset(buf, '\0', sizeof(buf));
if (plin->fwd) plin = plin->fwd;
- pos = snprintf(buf, sizeof(buf), "%s", plin->str);
+ pos = snprintf(buf, sizeof(buf), "%.*s", Screen_cols - beg - 1, plin->str);
break;
default: // what we REALLY wanted (maybe)
if (isprint(key) && logCOL < bufMAX && phyCOL < Screen_cols) {

View File

@ -50,36 +50,3 @@ diff -Naur procps-ng-3.3.8.orig/ps/output.c procps-ng-3.3.8/ps/output.c
#endif
From 4f0fe2993a92ac355ea8da3f1434cba0389ef389 Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Wed, 7 Aug 2013 12:58:57 -0500
Subject: [PATCH] ps: address a potential 'newline' quirk the libselinux
Sometimes with libselinux present but SELinux inactive
the context reported is "unconfined" which contains an
embedded newline. This then causes misalignment of any
subsequent data. So, ps will now protect against that.
Reference(s):
http://www.freelists.org/post/procps/enablelibselinux-switch,14
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
ps/output.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/ps/output.c b/ps/output.c
index b7b21d1..d457a89 100644
--- a/ps/output.c
+++ b/ps/output.c
@@ -1339,6 +1339,7 @@ static int pr_context(char *restrict const outbuf, const proc_t *restrict const
len = strlen(context);
if(len > max_len) len = max_len;
memcpy(outbuf, context, len);
+ if (outbuf[len-1] == '\n') --len;
outbuf[len] = '\0';
free(context);
}else{
--
1.8.1.2

View File

@ -1,3 +1,55 @@
-------------------------------------------------------------------
Thu May 15 11:50:39 UTC 2014 - werner@suse.de
- Fix missing job in D states in idle mode of top, therefore
update to latest top of procps-ng git HEAD
* Rename the patches
0001-top-enable-screen-contents-preservation-at-endofjob.patch
0001-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
0001-top-trade-two-groff_mdoc-macros-for-groff-equivalent.patch
0002-library-for-atexit-support-fix-fileutils-for-EPIPE.patch
0002-top-cursor-repositioning-includes-line-oriented-inpu.patch
to
0002-top-trade-two-groff_mdoc-macros-for-groff-equivalent.patch
0003-library-for-atexit-support-fix-fileutils-for-EPIPE.patch
0004-top-enable-screen-contents-preservation-at-end-of-jo.patch
0005-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
0006-top-cursor-repositioning-includes-line-oriented-inpu.patch
* Add upstream patches
0002-top-trade-two-groff_mdoc-macros-for-groff-equivalent.patch
0003-library-for-atexit-support-fix-fileutils-for-EPIPE.patch
0004-top-enable-screen-contents-preservation-at-end-of-jo.patch
0005-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
0006-top-cursor-repositioning-includes-line-oriented-inpu.patch
0007-top-correct-improve-or-otherwise-tweak-some-comments.patch
0008-top-tweak-cursor-state-code-to-swat-an-obscure-bugle.patch
0009-top-correct-cursor-positioning-for-all-Z-or-C-cases.patch
0010-ps-address-a-potential-newline-quirk-the-libselinux.patch
0012-top-hint-that-Summary-Area-cached-is-Mem-not-Swap.patch
0013-top-modest-efficiency-change-to-message-line-handlin.patch
0014-top-correct-improve-and-otherwise-tweak-configs_read.patch
0015-top-swat-bug-affecting-batch-mode-and-width-provisio.patch
0018-top-restore-the-lost-final-newline-when-in-Batch-mod.patch
0019-top-swat-bug-impacting-idle-mode-user-filtering.patch
0021-top-address-some-potential-libnuma-display-corruptio.patch
0022-top-fix-miscellaneous-spelling-errors-in-man-documen.patch
0023-top-expand-on-column-highlight-quirks-in-man-documen.patch
0024-top-add-some-flexibility-to-dlopen-for-numa-support.patch
0025-top-minimize-the-statistics-overhead-for-numa-suppor.patch
0026-top-eliminate-yet-more-gcc-subscript-resolution-bloa.patch
0032-top-do-not-lie-about-purported-alphabetical-ordering.patch
0033-top-follow-usual-name-conventions-for-global-variabl.patch
0035-top-provide-for-discontinuous-not-active-NUMA-nodes.patch
0036-top-restore-the-former-behavior-after-stderr-redirec.patch
0037-top-avoid-name-conflict-in-the-next-version-of-stdli.patch
0038-top-protect-against-distortion-when-system-time-rese.patch
0044-top-avoid-a-nan-when-the-delay-interval-is-very-low.patch
0045-top-standardize-Esc-key-support-with-prompted-input.patch
0046-top-miscellaneous-accumulated-changes-to-program-cod.patch
* Modify patches
0001-top-add-the-major-version-to-dlopen-of-libnuma-sonam.patch
procps-ng-3.3.8-libselinux.patch
-------------------------------------------------------------------
Tue Mar 25 12:43:12 CET 2014 - tiwai@suse.de

View File

@ -71,26 +71,78 @@ Patch18: procps-ng-3.3.8-petabytes.patch
Patch19: procps-v3.3.4-large_pcpu.patch
Patch20: procps-ng-3.3.8-tinfo.dif
Patch21: procps-v3.3.3-pwdx.patch
# PATCH-FIX-UPSTREAM -- Add the major version to dlopen of libnuma
Patch22: 0001-top-add-the-major-version-to-dlopen-of-libnuma-sonam.patch
# PATCH-FIX-UPSTREAM -- Use common mdoc nroff macros
Patch23: 0001-top-trade-two-groff_mdoc-macros-for-groff-equivalent.patch
# PATCH-FIX-UPSTREAM -- Let libproc support EPIPE in close_stream
Patch24: 0002-library-for-atexit-support-fix-fileutils-for-EPIPE.patch
# PATCH-FIX-UPSTREAM -- Do not clear screen after end-of-job
Patch25: 0001-top-enable-screen-contents-preservation-at-endofjob.patch
# PATCH-FIX-UPSTREAM -- Cursor repositioning includes line oriented input
Patch26: 0002-top-cursor-repositioning-includes-line-oriented-inpu.patch
# PATCH-FIX-UPSTREAM -- Suppress end-of-job report if top if not ended with 'q' key
Patch27: 0001-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
Patch22: 0003-library-for-atexit-support-fix-fileutils-for-EPIPE.patch
# PATCH-FIX-UPSTREAM -- Add enable-libselinux switch
Patch23: procps-ng-3.3.8-libselinux.patch
# PATCH-FIX-OPENSUSE -- trifle rest of the old terabyte patch
Patch28: procps-ng-3.3.8-vmstat-terabyte.dif
# PATCH-FIX-UPSTREAM -- Show shared memory in 'free' again
Patch29: procps-ng-3.3.8-shmem.patch
# PATCH-FIX-UPSTREAM -- Add enable-libselinux switch
Patch30: procps-ng-3.3.8-libselinux.patch
Patch30: 0010-ps-address-a-potential-newline-quirk-the-libselinux.patch
# PATCH-FIX-SUSE -- Ignore scan_unevictable_pages in sysctl
Patch31: procps-ng-3.3.8-ignore-scan_unevictable_pages.patch
# Top patches
# PATCH-FIX-UPSTREAM -- Add the major version to dlopen of libnuma
Patch100: 0001-top-add-the-major-version-to-dlopen-of-libnuma-sonam.patch
# PATCH-FIX-UPSTREAM -- Use common mdoc nroff macros
Patch101: 0002-top-trade-two-groff_mdoc-macros-for-groff-equivalent.patch
# PATCH-FIX-UPSTREAM -- Do not clear screen after end-of-job
Patch102: 0004-top-enable-screen-contents-preservation-at-end-of-jo.patch
# PATCH-FIX-UPSTREAM -- Suppress end-of-job report if top if not ended with 'q' key
Patch103: 0005-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
# PATCH-FIX-UPSTREAM -- Cursor repositioning includes line oriented input
Patch104: 0006-top-cursor-repositioning-includes-line-oriented-inpu.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch105: 0007-top-correct-improve-or-otherwise-tweak-some-comments.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch106: 0008-top-tweak-cursor-state-code-to-swat-an-obscure-bugle.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch107: 0009-top-correct-cursor-positioning-for-all-Z-or-C-cases.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch108: 0012-top-hint-that-Summary-Area-cached-is-Mem-not-Swap.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch109: 0013-top-modest-efficiency-change-to-message-line-handlin.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch110: 0014-top-correct-improve-and-otherwise-tweak-configs_read.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch111: 0015-top-swat-bug-affecting-batch-mode-and-width-provisio.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch112: 0018-top-restore-the-lost-final-newline-when-in-Batch-mod.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch113: 0019-top-swat-bug-impacting-idle-mode-user-filtering.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch114: 0021-top-address-some-potential-libnuma-display-corruptio.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch115: 0022-top-fix-miscellaneous-spelling-errors-in-man-documen.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch116: 0023-top-expand-on-column-highlight-quirks-in-man-documen.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch117: 0024-top-add-some-flexibility-to-dlopen-for-numa-support.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch118: 0025-top-minimize-the-statistics-overhead-for-numa-suppor.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch119: 0026-top-eliminate-yet-more-gcc-subscript-resolution-bloa.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch120: 0032-top-do-not-lie-about-purported-alphabetical-ordering.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch121: 0033-top-follow-usual-name-conventions-for-global-variabl.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch122: 0035-top-provide-for-discontinuous-not-active-NUMA-nodes.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch123: 0036-top-restore-the-former-behavior-after-stderr-redirec.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch124: 0037-top-avoid-name-conflict-in-the-next-version-of-stdli.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch125: 0038-top-protect-against-distortion-when-system-time-rese.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch126: 0044-top-avoid-a-nan-when-the-delay-interval-is-very-low.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch127: 0045-top-standardize-Esc-key-support-with-prompted-input.patch
# PATCH-FIX-UPSTREAM added at 2014/05/15
Patch128: 0046-top-miscellaneous-accumulated-changes-to-program-cod.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -156,16 +208,42 @@ the process information pseudo-file system,
%patch19
%patch20
%patch21
%patch22 -p1
%patch22
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28
%patch29 -p1
%patch30 -p1
%patch30
%patch31 -p1
# Patches for top
%patch100
%patch101
%patch102
%patch103
%patch104
%patch105
%patch106
%patch107
%patch108
%patch109
%patch110
%patch111
%patch112
%patch113
%patch114
%patch115
%patch116
%patch117
%patch118
%patch119
%patch120
%patch121
%patch122
%patch123
%patch124
%patch125
%patch126
%patch127
%patch128
%build
tar --strip-components=1 -xf %{S:1}
@ -188,6 +266,7 @@ export LFS_CFLAGS="$(getconf LFS_CFLAGS)"
--enable-w-from \
--enable-sigwinch \
--enable-wide-percent \
--enable-wide-memory \
--enable-w-from \
--enable-libselinux \
--with-pic=yes \