diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-05-20 14:41:34 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-05-20 14:42:05 +0200 |
commit | 0fa3c86f14e30690012db7b6d80f0b06f33660ff (patch) | |
tree | 725d73e03a68de78e3bca6be1e381888ad0c8dae | |
parent | 3fe70945a002917803e71dfc3e7cc08e0d435d87 (diff) |
Skip already terminated processes
Thanks to Christop Göhre for pointing this out
-rwxr-xr-x | whatmaps | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -23,6 +23,7 @@ import re import string import subprocess import sys +import errno from optparse import OptionParser try: import apt_pkg @@ -60,7 +61,13 @@ class Process(object): def _read_maps(self): """Read the SOs from /proc/<pid>/maps""" - for line in file('/proc/%d/maps' % self.pid): + try: + f = file('/proc/%d/maps' % self.pid) + except IOError as e: + # ignore killed process + if e.errno != errno.ENOENT: + raise + for line in f: try: so = line.split()[5].strip() self.mapped.append(so) |