From 23776571a74ce9c526b0171ca8ba7ec0357d8002 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sat, 7 Aug 2021 00:00:00 -0500 Subject: [PATCH] top: respond to that preceding fix in the 'select' i/f This patch makes it possible to honor our '-H' threads switch even when operating under that '-p' switch used to select/filter only certain pids. Of course, what we have done is just exploit the new library enhancement. [ and we're pretending we don't know the enumerators ] [ PIDS_FETCH_THREADS_TOO + PIDS_SELECT_PID are equal ] [ to that PIDS_SELECT_PID_THREADS enumerator itself. ] [ thankfully, those dependencies can be assured with ] [ a 'make check-lib' which exploits ITEMTABLE_DEBUG! ] Signed-off-by: Jim Warner --- top/top.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/top/top.c b/top/top.c index b0a65f06..1f0fbe8e 100644 --- a/top/top.c +++ b/top/top.c @@ -2389,7 +2389,7 @@ static void procs_refresh (void) { static int n_alloc = -1; // size of windows stacks arrays double uptime_cur; float et; - int i; + int i, what; procps_uptime(&uptime_cur, NULL); et = uptime_cur - uptime_sav; @@ -2398,8 +2398,12 @@ static void procs_refresh (void) { // if in Solaris mode, adjust our scaling for all cpus Frame_etscale = 100.0f / ((float)Hertz * (float)et * (Rc.mode_irixps ? 1 : Cpu_cnt)); - if (Monpidsidx) Pids_reap = procps_pids_select(Pids_ctx, Monpids, Monpidsidx, PIDS_SELECT_PID); - else Pids_reap = procps_pids_reap(Pids_ctx, Thread_mode ? PIDS_FETCH_THREADS_TOO : PIDS_FETCH_TASKS_ONLY); + what = Thread_mode ? PIDS_FETCH_THREADS_TOO : PIDS_FETCH_TASKS_ONLY; + if (Monpidsidx) { + what |= PIDS_SELECT_PID; + Pids_reap = procps_pids_select(Pids_ctx, Monpids, Monpidsidx, what); + } else + Pids_reap = procps_pids_reap(Pids_ctx, what); if (!Pids_reap) error_exit(fmtmk(N_fmt(LIB_errorpid_fmt),__LINE__, strerror(errno)));