]> granicus.if.org Git - procps-ng/commitdiff
top: respond to that preceding fix in the 'select' i/f
authorJim Warner <james.warner@comcast.net>
Sat, 7 Aug 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Mon, 9 Aug 2021 12:03:23 +0000 (22:03 +1000)
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 <james.warner@comcast.net>
top/top.c

index b0a65f068f0b10ccc285d73d994a9bbd760b0793..1f0fbe8e0b00f4c9bcbb60853a06479ea5d03161 100644 (file)
--- 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)));