summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-06-15 12:44:29 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-06-15 12:44:29 -0300
commit806a6247b9ef180105ed1e34cb4ad48bab712385 (patch)
treed0d2a58faae57344ef79fd6767cb74b0725033e1
parent2c94fc3e4a80850b1d5342091917702b33944448 (diff)
downloadpython-linux-procfs-806a6247b9ef180105ed1e34cb4ad48bab712385.tar.gz
pidstat: Support COMM names with spaces
The load method was just splitting the fields using space as the separator, but since some COMM names started having spaces... We better use the () as the COMM "quotes", using spaces as the separator for the remaining fields. Reported-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xprocfs/procfs.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py
index 6b4fd84..0ed55af 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -100,8 +100,9 @@ class pidstat:
def load(self, basedir = "/proc"):
f = open("%s/%d/stat" % (basedir, self.pid))
- fields = f.readline().strip().split()
+ fields = f.readline().strip().split(') ')
f.close()
+ fields = fields[0].split(' (') + fields[1].split()
self.fields = {}
nr_fields = min(len(fields), len(self.proc_stat_fields))
for i in range(nr_fields):