Blame SOURCES/BZ-1095150-needs-restarting-fixes.patch

5b4f08
diff -up yum-utils-1.1.31/needs-restarting.py.old yum-utils-1.1.31/needs-restarting.py
5b4f08
--- yum-utils-1.1.31/needs-restarting.py.old	2014-09-04 14:19:27.000000000 +0200
5b4f08
+++ yum-utils-1.1.31/needs-restarting.py	2014-09-04 14:29:47.825438668 +0200
5b4f08
@@ -44,6 +44,8 @@ import yum.misc
5b4f08
 import glob
5b4f08
 import stat
5b4f08
 from optparse import OptionParser
5b4f08
+sys.path.insert(0,'/usr/share/yum-cli')
5b4f08
+import utils
5b4f08
 
5b4f08
 def parseargs(args):
5b4f08
     usage = """
5b4f08
@@ -77,7 +79,8 @@ def get_open_files(pid):
5b4f08
     files = []
5b4f08
     smaps = '/proc/%s/smaps' % pid
5b4f08
     try:
5b4f08
-        maps = open(smaps, 'r').readlines()
5b4f08
+        with open(smaps, 'r') as maps_f:
5b4f08
+            maps = maps_f.readlines()
5b4f08
     except (IOError, OSError), e:
5b4f08
         print "Could not open %s" % smaps
5b4f08
         return files
5b4f08
@@ -88,7 +91,7 @@ def get_open_files(pid):
5b4f08
             continue
5b4f08
         line = line.replace('\n', '')
5b4f08
         filename = line[slash:]
5b4f08
-        #filename = filename.replace('(deleted)', '') #only mildly retarded
5b4f08
+        filename = filename.split(';')[0]
5b4f08
         filename = filename.strip()
5b4f08
         if filename not in files:
5b4f08
             files.append(filename)
5b4f08
@@ -109,10 +112,11 @@ def main(args):
5b4f08
     
5b4f08
     needing_restart = set()
5b4f08
 
5b4f08
+    boot_time = utils.get_boot_time()
5b4f08
     for pid in return_running_pids(uid=myuid):
5b4f08
         try:
5b4f08
-            pid_start = os.stat('/proc/' + pid)[stat.ST_CTIME]
5b4f08
-        except OSError, e:
5b4f08
+            pid_start = utils.get_process_time(int(pid), boot_time)['start_time']
5b4f08
+        except (OSError, IOError), e:
5b4f08
             continue
5b4f08
         found_match = False
5b4f08
         for fn in get_open_files(pid):
5b4f08
@@ -158,7 +162,7 @@ def main(args):
5b4f08
     for pid in needing_restart:
5b4f08
         try:
5b4f08
             cmdline = open('/proc/' +pid+ '/cmdline', 'r').read()
5b4f08
-        except OSError, e:
5b4f08
+        except (OSError, IOError), e:
5b4f08
             print "Couldn't access process information for %s: %s" % (pid, str(e))
5b4f08
             continue
5b4f08
         # proc cmdline is null-delimited so clean that up