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

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