Skip processes that no longer exist
authorPaul Wise <pabs@debian.org>
Tue, 6 Jan 2015 14:53:24 +0000 (22:53 +0800)
committerPaul Wise <pabs@debian.org>
Tue, 6 Jan 2015 14:53:24 +0000 (22:53 +0800)
modules/buildd/files/buildd-schroot-aptitude-kill

index 74c4a02..9a4d720 100755 (executable)
@@ -44,7 +44,13 @@ for p in psutil.process_iter():
                if parent is None: continue
                if parent.name != 'schroot': continue
                #
-               rootdir = os.readlink('/proc/%d/root'%(p.pid,))
+               try
+                       rootdir = os.readlink('/proc/%d/root'%(p.pid,))
+               except OSError as e:
+                       if e.errno == errno.ENOENT:
+                               continue
+                       else:
+                               raise e
                if not rootdir.startswith('/var/lib/schroot/mount'): continue
                #
                used = p.get_memory_info().vms