From 0fa3c86f14e30690012db7b6d80f0b06f33660ff Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 20 May 2012 14:41:34 +0200 Subject: Skip already terminated processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Christop Göhre for pointing this out --- whatmaps | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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//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) -- cgit v1.2.3