blob: fb89963bb9340f88e0d079a4d6b5d46322a70637 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <stdio.h>
#include <libcgroup.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
int ret, i;
char *group = NULL;
FILE *tasks = NULL;
if (argc < 2) {
printf("No list of groups provided\n");
return -1;
}
ret = cgroup_init();
if (ret) {
printf("cgroup_init failed with %s\n", cgroup_strerror(ret));
return -1;
}
for (i = 1; i < argc; i++) {
pid_t pid;
group = strdup(argv[i]);
printf("Printing the details of groups %s\n", group);
ret = cgroup_get_task_begin(group, "cpu", (void *) &tasks,
&pid);
while (!ret) {
printf("Pid is %u\n", pid);
ret = cgroup_get_task_next((void *) tasks, &pid);
if (ret && ret != ECGEOF) {
printf("cgroup_get_task_next failed with %s\n",
cgroup_strerror(ret));
if (ret == ECGOTHER)
printf("failure with %s\n",
strerror(errno));
return -1;
}
}
free(group);
group = NULL;
ret = cgroup_get_task_end((void **) &tasks);
}
return 0;
}
|