File: get_all_controller.c

package info (click to toggle)
libcgroup 3.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,764 kB
  • sloc: ansic: 14,997; cpp: 9,957; python: 8,340; sh: 5,194; yacc: 470; makefile: 400; lex: 38
file content (36 lines) | stat: -rw-r--r-- 759 bytes parent folder | download
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
// SPDX-License-Identifier: LGPL-2.1-only
#include <libcgroup.h>

#include <stdlib.h>
#include <stdio.h>

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

	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_controller_next failed with %s\n",
			       cgroup_strerror(error));
			exit(1);
		}
	}

	error = cgroup_get_all_controller_end(&handle);

	return 0;
}