1 |
--- procps-3.2.8/ps/output.c.cgroups 2010-09-18 11:44:38.000000000 +0400 |
2 |
+++ procps-3.2.8/ps/output.c 2010-09-18 11:45:20.000000000 +0400 |
3 |
@@ -1102,7 +1102,7 @@ static int pr_sgi_p(char *restrict const |
4 |
static int pr_cgroup(char *restrict const outbuf, const proc_t *restrict const pp){ |
5 |
char filename[48]; |
6 |
FILE *fd; |
7 |
- int counter = 0; |
8 |
+ int counter = 0, last_begin = 0, slash = 0; |
9 |
int c; |
10 |
int is_cgroup = 0; |
11 |
|
12 |
@@ -1114,15 +1114,22 @@ static int pr_cgroup(char *restrict cons |
13 |
if (is_cgroup == 0) { |
14 |
if (c == ':') { |
15 |
is_cgroup = 1; |
16 |
+ slash = 0; |
17 |
if (counter>0) |
18 |
outbuf[counter++]=';'; |
19 |
} |
20 |
}else |
21 |
- if ((c == '\n') || (c == '\0')) |
22 |
- is_cgroup = 0; |
23 |
+ if ((c == '\n') || (c == '\0')){ |
24 |
+ if (slash) /* if the last char was a / this process is in the root cgroup which we should suppress */ |
25 |
+ counter = last_begin; |
26 |
else |
27 |
+ last_begin = counter; |
28 |
+ is_cgroup = 0; |
29 |
+ } else { |
30 |
+ slash = c == '/'; |
31 |
outbuf[counter++]=c; |
32 |
} |
33 |
+ } |
34 |
outbuf[counter]='\0'; |
35 |
close(fd); |
36 |
if (counter>0) |