diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-12-08 13:44:21 -0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-12-08 13:44:21 -0200 |
commit | 6f10fcb15911aec0d49c1426433e77228ccc38a4 (patch) | |
tree | cb0c0e55423f79d0d34874682440c2b96b68618b | |
parent | ba15d16378c5d83638cb16ce2eee9948f6d99059 (diff) | |
download | python-linux-procfs-6f10fcb15911aec0d49c1426433e77228ccc38a4.tar.gz |
process: Always set the "cmdline" array, even if emptyv0.4.1
So that we don't require the tools that use p-l-procfs to call load_cmdline
everytime we refresh the list of processes, leaving parsing of /proc/cmdline to
the last possible moment.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | procfs/procfs.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py index c972438..7b27f31 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -7,7 +7,7 @@ import os, time, utilist VERSION="0.2" def process_cmdline(pid_info): - if pid_info.has_key("cmdline"): + if pid_info["cmdline"]: return reduce(lambda a, b: a + " %s" % b, pid_info["cmdline"]).strip() return pid_info["stat"]["comm"] @@ -157,11 +157,8 @@ class process: def load_cmdline(self): f = file("/proc/%d/cmdline" % self.pid) - line = f.readline() + self.cmdline = f.readline().strip().split('\0')[:-1] f.close() - if line: - self.cmdline = line.strip().split('\0') - print "pid: %d, cmdline=(%s)" % (self.pid, self.cmdline) def load_threads(self): self.threads = pidstats("/proc/%d/task/" % self.pid) |