Blame SOURCES/0001-pidstat-Display-stats-since-boot-time-for-a-list-of-.patch

67ba6f
From b4cad00cfb3086490261db7202de8ed846e79344 Mon Sep 17 00:00:00 2001
67ba6f
From: Sebastien GODARD <sysstat@orange.fr.fake>
67ba6f
Date: Wed, 2 Oct 2013 09:55:38 +0200
67ba6f
Subject: [PATCH] pidstat: Display stats since boot time for a list of given
67ba6f
 processes
67ba6f
67ba6f
pidstat displays statistics since system startup when the interval and
67ba6f
count parameters are not set on the command line (eg. entering "pidstat
67ba6f
-d" will display I/O statistics for all processes that have had I/O
67ba6f
activity since boot time). But pidstat couldn't display those stats when
67ba6f
some PID numbers were entered on the command line (eg. "pidstat -d -p
67ba6f
1234" to display I/O stats since system startup for process 1234).
67ba6f
This patch makes it possible now.
67ba6f
67ba6f
Signed-off-by: Sebastien GODARD <sysstat@orange.fr.fake>
67ba6f
(cherry picked from commit 18c7a03f52826942a720b2a0cc32e1f074784c6a)
67ba6f
67ba6f
Resolves: #1448489
67ba6f
---
67ba6f
 pidstat.c | 16 ++++++++++++----
67ba6f
 1 file changed, 12 insertions(+), 4 deletions(-)
67ba6f
67ba6f
diff --git a/pidstat.c b/pidstat.c
67ba6f
index 3bb98f2..85d4d98 100644
67ba6f
--- a/pidstat.c
67ba6f
+++ b/pidstat.c
67ba6f
@@ -1048,10 +1048,18 @@ int get_pid_to_display(int prev, int curr, int p, unsigned int activity,
67ba6f
 	
67ba6f
 	else if (DISPLAY_PID(pidflag)) {
67ba6f
 		*pstp = st_pid_list[prev] + p;
67ba6f
-
67ba6f
-		if (!(*pstp)->pid)
67ba6f
-			/* PID no longer exists */
67ba6f
-			return 0;
67ba6f
+		if (!(*pstp)->pid) {
67ba6f
+			if (interval)
67ba6f
+				/* PID no longer exists */
67ba6f
+				return 0;
67ba6f
+			else {
67ba6f
+				/*
67ba6f
+				 * If interval is null, then we are trying to
67ba6f
+				 * display stats for a given process since boot time.
67ba6f
+				 */
67ba6f
+				*pstp = &st_pid_null;
67ba6f
+			}
67ba6f
+		}
67ba6f
 	}
67ba6f
 
67ba6f
 	if (COMMAND_STRING(pidflag)) {
67ba6f
-- 
67ba6f
2.13.6
67ba6f