Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
procps.10047
0036-top-restore-the-former-behavior-after-stde...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0036-top-restore-the-former-behavior-after-stderr-redirec.patch of Package procps.10047
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
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor