diff options
Diffstat (limited to 'src/firemon/top.c')
-rw-r--r-- | src/firemon/top.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/firemon/top.c b/src/firemon/top.c index 3a79a5260..3d657a6a6 100644 --- a/src/firemon/top.c +++ b/src/firemon/top.c | |||
@@ -54,6 +54,9 @@ static char *get_header(void) { | |||
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | static char *firejail_exec = NULL; | ||
58 | static int firejail_exec_len = 0; | ||
59 | static int firejail_exec_prefix_len = 0; | ||
57 | // recursivity!!! | 60 | // recursivity!!! |
58 | static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigned *stime, unsigned itv, float *cpu, int *cnt) { | 61 | static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigned *stime, unsigned itv, float *cpu, int *cnt) { |
59 | char *rv = NULL; | 62 | char *rv = NULL; |
@@ -90,6 +93,13 @@ static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigne | |||
90 | print_top(i, index, utime, stime, itv, cpu, cnt); | 93 | print_top(i, index, utime, stime, itv, cpu, cnt); |
91 | } | 94 | } |
92 | 95 | ||
96 | if (!firejail_exec) { | ||
97 | if (asprintf(&firejail_exec, "%s/bin/firejail", PREFIX) == -1) | ||
98 | errExit("asprintf"); | ||
99 | firejail_exec_len = strlen(firejail_exec); | ||
100 | firejail_exec_prefix_len = strlen(PREFIX) + 5; | ||
101 | } | ||
102 | |||
93 | if (pids[index].level == 1) { | 103 | if (pids[index].level == 1) { |
94 | // pid | 104 | // pid |
95 | char pidstr[10]; | 105 | char pidstr[10]; |
@@ -104,8 +114,8 @@ static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigne | |||
104 | else | 114 | else |
105 | ptrcmd = ""; | 115 | ptrcmd = ""; |
106 | } | 116 | } |
107 | else if (strncmp(cmd, "/usr/bin/firejail", 17) == 0) | 117 | else if (strncmp(cmd, firejail_exec, firejail_exec_len) == 0) |
108 | ptrcmd = cmd + 9; | 118 | ptrcmd = cmd + firejail_exec_prefix_len; |
109 | else | 119 | else |
110 | ptrcmd = cmd; | 120 | ptrcmd = cmd; |
111 | 121 | ||