]> granicus.if.org Git - sysstat/commitdiff
pidstat: Simplify use of P_D_PID flag
authorSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 27 Apr 2021 06:58:47 +0000 (08:58 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 27 Apr 2021 06:58:47 +0000 (08:58 +0200)
P_D_PID flag is set only when option -p is used on the command line.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
pidstat.c

index c7c3c35bb78893f2a5025f59b72b27e962e95b00..78dad1cf10e1dfc30170524919fcea2a88013627 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -185,7 +185,11 @@ void check_flags(void)
        }
 
        if (!DISPLAY_PID(pidflag)) {
-               pidflag |= P_D_ACTIVE_PID + P_D_PID + P_D_ALL_PID;
+               /*
+                * If no PIDs nor -p ALL entered on the command line then
+                * only active PIDs will be displayed.
+                */
+               pidflag |= P_D_ACTIVE_PID + P_D_ALL_PID;
        }
 
        if (!tskflag) {
@@ -972,7 +976,7 @@ void read_stats(int curr)
                __closedir(dir);
        }
 
-       else if (DISPLAY_PID(pidflag)) {
+       else {
                /* Read stats for each PID in the list */
                for (plist = pid_list; plist != NULL; plist = plist->next) {