es-que / cpuset

Automatically exported from code.google.com/p/cpuset
GNU General Public License v2.0
0 stars 0 forks source link

cset crashes if /proc/<pid>/stat contains spaces in process name #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Call "cset shield --unshield -v" on a plain Ubuntu

What is the expected output? What do you see instead?

Traceback (most recent call last):
  File "/usr/bin/cset", line 47, in <module>
    main()
  File "/usr/lib/pymodules/python2.7/cpuset/main.py", line 228, in main
    command.func(parser, options, args)
  File "/usr/lib/pymodules/python2.7/cpuset/commands/shield.py", line 291, in func
    print_stats()
  File "/usr/lib/pymodules/python2.7/cpuset/commands/shield.py", line 315, in print_sys_stats
    proc.log_detailed_task_table(cset.unique_set(SYS_SET), '   ', 76)
  File "/usr/lib/pymodules/python2.7/cpuset/commands/proc.py", line 787, in log_detailed_task_table
    l.extend(task_detail_table(set.tasks, indent, width))
  File "/usr/lib/pymodules/python2.7/cpuset/commands/proc.py", line 776, in task_detail_table
    if width: l.append(istr + task_detail(task, width))
  File "/usr/lib/pymodules/python2.7/cpuset/commands/proc.py", line 730, in task_detail
    out2.append(policy[int(stat[statdef['rtpolicy']])])
IndexError: list index out of range

The problem is that some processes have spaces in their process name, e.g.:

# cat /proc/2845/stat
2845 (alsa-sink-HDMI ) S 2634 2833 2833 0 -1 4218944 3621 0 4 0 13 12 0 0 -6 
-11 4 0 6386 463695872 1657 18446744073709551615 4194304 4273956 
140722199213344 139661618646368 139661677494767 0 0 3674112 19011 
18446744073709551615 0 0 -1 7 5 2 0 0 0 6375016 6377584 36630528 
140722199217975 140722199218023 140722199218023 140722199220196 0
# cat /proc/26638/stat
26638 (DNS Res~ver #16) S 2863 2781 2781 0 -1 1077960768 536802 3650 138 0 
11390 905 1 0 20 0 51 0 771645 1537323008 136670 18446744073709551615 
139959562293248 139959562399028 140732783909232 139958028811552 139959557875662 
0 0 4096 33572079 18446744073709551615 0 0 -1 7 0 0 0 0 0 139959564499304 
139959564501112 139959593127936 140732783916821 140732783916846 140732783916846 
140732783919071 0

This is not handled by the "stat = stat.split()" in task_detail() in proc.py.

What version of the product are you using? On what operating system?

cset 1.5.6, Linux 3.13.0-49 on Ubuntu 14.04, x86_64

Original issue reported on code.google.com by boris1...@nurfuerspam.de on 30 Apr 2015 at 9:57