diff --git a/top/top.c b/top/top.c index cb1a063b..23dad928 100644 --- a/top/top.c +++ b/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 a/top/top.h b/top/top.h index 8e83b617..862568c1 100644 --- a/top/top.h +++ b/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) */