summaryrefslogtreecommitdiffstats
path: root/tests/get_all_controller.c
blob: 3df3ca88e1423887302c463847b47e1d79372b13 (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
#include <libcgroup.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int error;
	void *handle;
	struct controller_data info;

	error = cgroup_init();

	if (error) {
		printf("cgroup_init failed with %s\n", cgroup_strerror(error));
		exit(1);
	}

	error = cgroup_get_all_controller_begin(&handle, &info);

	while (error != ECGEOF) {
		printf("Controller %10s %5d %5d %5d\n", info.name,
			info.hierarchy, info.num_cgroups, info.enabled);
		error = cgroup_get_all_controller_next(&handle, &info);
		if (error && error != ECGEOF) {
			printf("cgroup_get_contrller_next failed with %s\n",
							cgroup_strerror(error));
			exit(1);
		}
	}

	error = cgroup_get_all_controller_end(&handle);

	return 0;
}