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