diff options
Diffstat (limited to 'src/firemon/cgroup.c')
-rw-r--r-- | src/firemon/cgroup.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/firemon/cgroup.c b/src/firemon/cgroup.c deleted file mode 100644 index 8dbf85824..000000000 --- a/src/firemon/cgroup.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2018 Firejail Authors | ||
3 | * | ||
4 | * This file is part of firejail project | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | #include "firemon.h" | ||
21 | #define MAXBUF 4098 | ||
22 | |||
23 | static void print_cgroup(int pid) { | ||
24 | char *file; | ||
25 | if (asprintf(&file, "/proc/%d/cgroup", pid) == -1) { | ||
26 | errExit("asprintf"); | ||
27 | exit(1); | ||
28 | } | ||
29 | |||
30 | FILE *fp = fopen(file, "r"); | ||
31 | if (!fp) { | ||
32 | printf(" Error: cannot open %s\n", file); | ||
33 | free(file); | ||
34 | return; | ||
35 | } | ||
36 | |||
37 | char buf[MAXBUF]; | ||
38 | if (fgets(buf, MAXBUF, fp)) { | ||
39 | printf(" %s", buf); | ||
40 | fflush(0); | ||
41 | } | ||
42 | |||
43 | fclose(fp); | ||
44 | free(file); | ||
45 | } | ||
46 | |||
47 | void cgroup(pid_t pid, int print_procs) { | ||
48 | pid_read(pid); | ||
49 | |||
50 | // print processes | ||
51 | printf(" cgroup: "); | ||
52 | int i; | ||
53 | for (i = 0; i < max_pids; i++) { | ||
54 | if (pids[i].level == 1) { | ||
55 | if (print_procs || pid == 0) | ||
56 | pid_print_list(i, arg_nowrap); | ||
57 | int child = find_child(i); | ||
58 | if (child != -1) | ||
59 | print_cgroup(child); | ||
60 | } | ||
61 | } | ||
62 | printf("\n"); | ||
63 | } | ||