forked from pool/cpuset
ae928f1f52
- Merge new cpuset upstream. Update URL, and add post v1.5.6 fixes. - New patches: Fix-crash-with-SCHED_IDLE-policy.patch (bnc#959992) Handle-unknown-scheduler-policy-codes-gracefully.patch (bnc#959992) Parse-proc-pid-stat-properly.patch Docu-remove-mention-about-nonexistent-option.patch (bnc#957323) Docu-fix-asciidoc-build-error.patch Update-URLs-after-project-migration.patch Docu-fixed-a-typo.patch Fix-typo-in-setup-py.patch OBS-URL: https://build.opensuse.org/request/show/351159 OBS-URL: https://build.opensuse.org/package/show/hardware/cpuset?expand=0&rev=24
31 lines
1.2 KiB
Diff
31 lines
1.2 KiB
Diff
From 226c8185d4f59cdbcc2116b7bf5df1f44fc59aa4 Mon Sep 17 00:00:00 2001
|
|
From: Libor Pechacek <lpechacek@suse.com>
|
|
Date: Tue, 22 Dec 2015 15:10:55 +0100
|
|
Subject: [PATCH] Parse /proc/<pid>/stat properly
|
|
References:
|
|
|
|
Process names can contain spaces. Handle these cases correctly.
|
|
|
|
Signed-off-by: Libor Pechacek <lpechacek@suse.com>
|
|
Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
|
|
---
|
|
cpuset/commands/proc.py | 7 ++++++-
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
--- a/cpuset/commands/proc.py
|
|
+++ b/cpuset/commands/proc.py
|
|
@@ -711,7 +711,12 @@ options = [make_option('-l', '--list',
|
|
except:
|
|
pass # sometimes, we get an extra \n out of this file...
|
|
stat = file('/proc/'+pid+'/stat', 'r').readline()
|
|
- stat = stat.split()
|
|
+ # we assume parentheses appear only around the name
|
|
+ stat_right_paren = stat.rfind(')')
|
|
+ stat_left_paren = stat.find('(')
|
|
+ stat = [stat[:stat_left_paren-1]] + \
|
|
+ [stat[stat_left_paren:stat_right_paren+1]] + \
|
|
+ stat[stat_right_paren+2:].split()
|
|
cmdline = file('/proc/'+pid+'/cmdline').readline()
|
|
# assume that a zero delimits the cmdline (it does now...)
|
|
cmdline = cmdline.replace('\0', ' ')
|