diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-30 11:28:31 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-30 11:28:31 -0300 |
commit | 6b3db2a61598588e0eac3bb3cb93aeee0e2caa42 (patch) | |
tree | 2e6ddb92a5f009f6ec0635e4cf9c12524ede254a | |
parent | 4a0cdd1cea29f54317036db9b396bc37b7ffa3e3 (diff) | |
download | python-linux-procfs-6b3db2a61598588e0eac3bb3cb93aeee0e2caa42.tar.gz |
smaps: Improve parsing of mmaps
Recent kernels (detected on 3.9.0-rc2) have a VmFlags field that has
string flags that broke the detection of multiple memory maps.
Fix it by checking for a ':' as the last character of the first
token in the split() line.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | procfs/procfs.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py index ab6cfa4..c0ceec8 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -462,7 +462,12 @@ class smaps_lib: self.tags = {} for line in lines[1:]: fields = line.split() - self.tags[fields[0][:-1].lower()] = int(fields[1]) + tag = fields[0][:-1].lower() + try: + self.tags[tag] = int(fields[1]) + except: + # VmFlags are strings + self.tags[tag] = fields def __getitem__(self, key): return self.tags[key.lower()] @@ -489,7 +494,7 @@ class smaps: if not line: break line = line.strip() - if len(line.split()) < 4: + if line.split()[0][-1] == ':': lines.append(line) else: break |