Blame SOURCES/BZ-1138205-needs-restarting.patch

65829f
commit 7ef0f4ad556e3d4bfe0eeebd1f110de745adec3c
65829f
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
65829f
Date:   Wed Mar 19 16:24:58 2014 +0100
65829f
65829f
    Make utils.get_process_info() respect executable names with spaces.
65829f
65829f
diff --git a/utils.py b/utils.py
65829f
index 0b7191c..b00d312 100755
65829f
--- a/utils.py
65829f
+++ b/utils.py
65829f
@@ -114,18 +114,20 @@ def get_process_info(pid):
65829f
             break
65829f
     if boot_time is None:
65829f
         return
65829f
-    ps_stat = open("/proc/%d/stat" % pid).read().split()
65829f
-    ps['utime'] = jiffies_to_seconds(ps_stat[13])
65829f
-    ps['stime'] = jiffies_to_seconds(ps_stat[14])
65829f
-    ps['cutime'] = jiffies_to_seconds(ps_stat[15])
65829f
-    ps['cstime'] = jiffies_to_seconds(ps_stat[16])
65829f
-    ps['start_time'] = boot_time + jiffies_to_seconds(ps_stat[21])
65829f
+    ps_stat = open("/proc/%d/stat" % pid).read().strip()
65829f
+    # Filename of the executable might contain spaces, so we throw it away
65829f
+    ps_stat = ps_stat[ps_stat.rfind(')') + 2:].split()
65829f
+    ps['utime'] = jiffies_to_seconds(ps_stat[11])
65829f
+    ps['stime'] = jiffies_to_seconds(ps_stat[12])
65829f
+    ps['cutime'] = jiffies_to_seconds(ps_stat[13])
65829f
+    ps['cstime'] = jiffies_to_seconds(ps_stat[14])
65829f
+    ps['start_time'] = boot_time + jiffies_to_seconds(ps_stat[19])
65829f
     ps['state'] = {'R' : _('Running'),
65829f
                    'S' : _('Sleeping'),
65829f
                    'D' : _('Uninterruptible'),
65829f
                    'Z' : _('Zombie'),
65829f
                    'T' : _('Traced/Stopped')
65829f
-                   }.get(ps_stat[2], _('Unknown'))
65829f
+                   }.get(ps_stat[0], _('Unknown'))
65829f
                    
65829f
     return ps
65829f
 
65829f
commit cf0464bea74f6e8d4650afee4e66d66bff2bc9a1
65829f
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
65829f
Date:   Wed Mar 19 17:19:32 2014 +0100
65829f
65829f
    Refactored utils.get_process_info() to make parts of it reusable.
65829f
65829f
diff --git a/utils.py b/utils.py
65829f
index b00d312..dbcd605 100755
65829f
--- a/utils.py
65829f
+++ b/utils.py
65829f
@@ -107,13 +107,21 @@ def get_process_info(pid):
65829f
         return
65829f
     if 'vmsize' not in ps:
65829f
         return
65829f
-    boot_time = None
65829f
-    for line in open("/proc/stat"):
65829f
-        if line.startswith("btime "):
65829f
-            boot_time = int(line[len("btime "):-1])
65829f
-            break
65829f
+    boot_time = get_boot_time()
65829f
     if boot_time is None:
65829f
         return
65829f
+    ps.update(get_process_time(pid, boot_time))
65829f
+    return ps
65829f
+
65829f
+
65829f
+def get_boot_time():
65829f
+    for line in open("/proc/stat"):
65829f
+        if line.startswith("btime "):
65829f
+            return int(line[len("btime "):-1])
65829f
+
65829f
+
65829f
+def get_process_time(pid, boot_time):
65829f
+    ps = {}
65829f
     ps_stat = open("/proc/%d/stat" % pid).read().strip()
65829f
     # Filename of the executable might contain spaces, so we throw it away
65829f
     ps_stat = ps_stat[ps_stat.rfind(')') + 2:].split()