Accepting request 184310 from Base:System

- Add three upstream patches
  0001-top-enable-screen-contents-preservation-at-endofjob.patch
  0001-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
  0002-top-cursor-repositioning-includes-line-oriented-inpu.patch

OBS-URL: https://build.opensuse.org/request/show/184310
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/procps?expand=0&rev=76
This commit is contained in:
Stephan Kulow 2013-07-25 13:15:21 +00:00 committed by Git OBS Bridge
parent 693e2d9a3f
commit 27601165fb
5 changed files with 407 additions and 0 deletions

View File

@ -0,0 +1,98 @@
Signed-off-by: Jim Warner <james.warner@xxxxxxxxxxx>
---
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
@@ -72,8 +72,9 @@ static struct termios Tty_original, // our inherited terminal definition
Tty_raw; // for unsolicited input
static int Ttychanged = 0;
- /* Last established cursor state/shape */
+ /* Last established cursor state/shape, and is re-position needed */
static const char *Cursor_state = "";
+static int Cursor_repos;
/* Program name used in error messages and local 'rc' file name */
static char *Myname;
@@ -350,12 +351,15 @@ 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("\n");
+#ifdef OFF_SCROLLBK
if (exit_ca_mode) {
// this next will also replace top's most recent screen with the
// original display contents that were visible at our invocation
putp(exit_ca_mode);
}
+#endif
putp(Cap_curs_norm);
putp(Cap_clr_eol);
#ifndef RMAN_IGNORED
@@ -591,17 +595,13 @@ static void sig_endpgm (int dont_care_sig) {
/*
* Catches:
- * SIGTSTP, SIGTTIN and SIGTTOU
- * note:
- * we don't fiddle with with those enter/exit_ca_mode strings
- * because we want to retain most of the last screen contents
- * as a visual reminder this program is suspended, not ended! */
+ * SIGTSTP, SIGTTIN and SIGTTOU */
static void sig_paused (int dont_care_sig) {
// POSIX.1-2004 async-signal-safe: tcsetattr, tcdrain, raise
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);
- putp(tg2(0, Screen_rows));
+ if (Cursor_repos) putp(tg2(0, Screen_rows));
putp(Cap_curs_norm);
#ifndef RMAN_IGNORED
putp(Cap_smam);
@@ -2120,6 +2120,7 @@ static void fields_utility (void) {
int i, key;
FLG_t f;
+ Cursor_repos = 1;
spewFI
signify_that:
putp(Cap_clr_scr);
@@ -2180,6 +2181,7 @@ signify_that:
break;
}
} while (key != 'q' && key != kbd_ESC);
+ Cursor_repos = 0;
#undef unSCRL
#undef swapEM
#undef spewFI
@@ -3768,8 +3770,10 @@ static void whack_terminal (void) {
// thanks anyway stdio, but we'll manage buffering at the frame level...
setbuffer(stdout, Stdout_buf, sizeof(Stdout_buf));
#endif
+#ifdef OFF_SCROLLBK
// this has the effect of disabling any troublesome scrollback buffer...
if (enter_ca_mode) putp(enter_ca_mode);
+#endif
// 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
index f356798..a8a7357 100644
--- a/top/top.h
+++ b/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 */
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
+//#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) */
--
1.8.1.2

View File

@ -0,0 +1,232 @@
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

View File

@ -0,0 +1,60 @@
From eee15b862dd5b051f16c719bf3c974591783a8f8 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
A recent patch introduced the ability to recognize the
need to reposition the cursor at suspension or program
end. There remained unmet 1 additional potential need.
This commit extends that ability to embrace line input
so that if a user issues ^Z or ^C while being prompted
the resulting shell output will no longer be embedded.
Reference(s):
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,7
commit 5c974ff44da4fbbb9170dd15bdd81555c62c31a9
Signed-off-by: Jim Warner <james.warner@comcast.net>
---
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
@@ -1081,12 +1081,14 @@ 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
@@ -1117,6 +1119,7 @@ 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
@@ -1182,6 +1185,7 @@ 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
--
1.8.1.2

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Jul 25 11:31:34 UTC 2013 - werner@suse.de
- Add three upstream patches
0001-top-enable-screen-contents-preservation-at-endofjob.patch
0001-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
0002-top-cursor-repositioning-includes-line-oriented-inpu.patch
-------------------------------------------------------------------
Wed Jun 26 14:17:34 UTC 2013 - werner@suse.de

View File

@ -77,6 +77,12 @@ Patch22: 0001-top-add-the-major-version-to-dlopen-of-libnuma-sonam.patch
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
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -145,6 +151,9 @@ the process information pseudo-file system,
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%build
test -s .tarball-version || echo %{version} > .tarball-version