diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c index 54f0c5fc913..147b5073b7a 100644 --- a/src/firemon/firemon.c +++ b/src/firemon/firemon.c @@ -25,6 +25,7 @@ #include #include +pid_t skip_process = 0; static int arg_route = 0; static int arg_arp = 0; static int arg_tree = 0; @@ -217,6 +218,13 @@ int main(int argc, char **argv) { } } + + // if the parent is firejail, skip the process + pid_t ppid = getppid(); + char *pcomm = pid_proc_comm(ppid); + if (pcomm && strcmp(pcomm, "firejail") == 0) + skip_process = ppid; + // allow only root user if /proc is mounted hidepid if (pid_hidepid() && getuid() != 0) { fprintf(stderr, "Error: /proc is mounted hidepid, you would need to be root to run this command\n"); diff --git a/src/firemon/firemon.h b/src/firemon/firemon.h index 2e04666385a..e5a528254f5 100644 --- a/src/firemon/firemon.h +++ b/src/firemon/firemon.h @@ -36,6 +36,7 @@ static inline void firemon_clrscr(void) { } // firemon.c +extern pid_t skip_process; extern int arg_nowrap; int find_child(int id); void firemon_sleep(int st); diff --git a/src/firemon/list.c b/src/firemon/list.c index 846739af5c0..cc1a871c6ad 100644 --- a/src/firemon/list.c +++ b/src/firemon/list.c @@ -25,6 +25,8 @@ void list(void) { // print processes int i; for (i = 0; i < max_pids; i++) { + if (i == skip_process) + continue; if (pids[i].level == 1) pid_print_list(i, arg_nowrap); } diff --git a/src/firemon/top.c b/src/firemon/top.c index d60a0baef27..b8dd92b3ccd 100644 --- a/src/firemon/top.c +++ b/src/firemon/top.c @@ -273,6 +273,8 @@ void top(void) { unsigned utime = 0; unsigned stime = 0; for (i = 0; i < max_pids; i++) { + if (i == skip_process) + continue; if (pids[i].level == 1) pid_store_cpu(i, 0, &utime, &stime); } @@ -313,6 +315,8 @@ void top(void) { // print processes for (i = 0; i < max_pids; i++) { + if (i == skip_process) + continue; if (pids[i].level == 1) { float cpu = 0; int cnt = 0; // process count diff --git a/src/firemon/tree.c b/src/firemon/tree.c index 99a7f3d889e..07680d6d51f 100644 --- a/src/firemon/tree.c +++ b/src/firemon/tree.c @@ -25,6 +25,8 @@ void tree(pid_t pid) { // print processes int i; for (i = 0; i < max_pids; i++) { + if (i == skip_process) + continue; if (pids[i].level == 1) pid_print_tree(i, 0, arg_nowrap); }