aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2012-05-20 14:41:34 +0200
committerGuido Günther <agx@sigxcpu.org>2012-05-20 14:42:05 +0200
commit0fa3c86f14e30690012db7b6d80f0b06f33660ff (patch)
tree725d73e03a68de78e3bca6be1e381888ad0c8dae
parent3fe70945a002917803e71dfc3e7cc08e0d435d87 (diff)
Skip already terminated processes
Thanks to Christop Göhre for pointing this out
-rwxr-xr-xwhatmaps9
1 files changed, 8 insertions, 1 deletions
diff --git a/whatmaps b/whatmaps
index a5c6a8b..8c4964b 100755
--- a/whatmaps
+++ b/whatmaps
@@ -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)