aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README1
-rw-r--r--src/firecfg/main.c5
-rw-r--r--src/firemon/top.c24
3 files changed, 23 insertions, 7 deletions
diff --git a/README b/README
index e98b6354a..1208e1644 100644
--- a/README
+++ b/README
@@ -392,6 +392,7 @@ startx2017 (https://github.com/startx2017)
392 - firejail.config cleanup 392 - firejail.config cleanup
393 - --quiet fixes 393 - --quiet fixes
394 - 0.9.38-LTS branch maintainer 394 - 0.9.38-LTS branch maintainer
395 - firemon --top speed-up
395thewisenerd (https://github.com/thewisenerd) 396thewisenerd (https://github.com/thewisenerd)
396 - allow multiple private-home commands 397 - allow multiple private-home commands
397 - use $SHELL variable if the shell is not specified 398 - use $SHELL variable if the shell is not specified
diff --git a/src/firecfg/main.c b/src/firecfg/main.c
index 7d63cb848..c8af9d03a 100644
--- a/src/firecfg/main.c
+++ b/src/firecfg/main.c
@@ -218,10 +218,7 @@ static void set_file(const char *name, const char *firejail_exec) {
218 errExit("asprintf"); 218 errExit("asprintf");
219 219
220 struct stat s; 220 struct stat s;
221 if (stat(fname, &s) == 0) { 221 if (stat(fname, &s) != 0) {
222 printf(" %s is already present, skipping...\n", name);
223 }
224 else {
225 int rv = symlink(firejail_exec, fname); 222 int rv = symlink(firejail_exec, fname);
226 if (rv) { 223 if (rv) {
227 fprintf(stderr, "Error: cannot create %s symbolic link\n", fname); 224 fprintf(stderr, "Error: cannot create %s symbolic link\n", fname);
diff --git a/src/firemon/top.c b/src/firemon/top.c
index 73661a07a..081f04eba 100644
--- a/src/firemon/top.c
+++ b/src/firemon/top.c
@@ -28,6 +28,21 @@ static unsigned pgs_rss = 0;
28static unsigned pgs_shared = 0; 28static unsigned pgs_shared = 0;
29static unsigned clocktick = 0; 29static unsigned clocktick = 0;
30static unsigned long long sysuptime = 0; 30static unsigned long long sysuptime = 0;
31static int pgsz = 0;
32static uid_t cached_uid = 0;
33static char *cached_user_name = NULL;
34
35static char *get_user_name(uid_t uid) {
36 if (cached_user_name == NULL) {
37 cached_uid = uid;
38 cached_user_name = pid_get_user_name(uid);
39 return strdup(cached_user_name);
40 }
41 else if (uid == cached_uid)
42 return strdup(cached_user_name);
43 else
44 return pid_get_user_name(uid);
45}
31 46
32static char *get_header(void) { 47static char *get_header(void) {
33 char *rv; 48 char *rv;
@@ -89,11 +104,13 @@ static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigne
89 else 104 else
90 ptrcmd = ""; 105 ptrcmd = "";
91 } 106 }
107 else if (strncmp(cmd, "/usr/bin/firejail", 17) == 0)
108 ptrcmd = cmd + 9;
92 else 109 else
93 ptrcmd = cmd; 110 ptrcmd = cmd;
94 111
95 // user 112 // user
96 char *user = pid_get_user_name(pids[index].uid); 113 char *user = get_user_name(pids[index].uid);
97 char *ptruser; 114 char *ptruser;
98 if (user) 115 if (user)
99 ptruser = user; 116 ptruser = user;
@@ -101,7 +118,8 @@ static char *print_top(unsigned index, unsigned parent, unsigned *utime, unsigne
101 ptruser = ""; 118 ptruser = "";
102 119
103 // memory 120 // memory
104 int pgsz = getpagesize(); 121 if (pgsz == 0)
122 pgsz = getpagesize();
105 char rss[10]; 123 char rss[10];
106 snprintf(rss, 10, "%u", pgs_rss * pgsz / 1024); 124 snprintf(rss, 10, "%u", pgs_rss * pgsz / 1024);
107 char shared[10]; 125 char shared[10];
@@ -249,7 +267,7 @@ void top(void) {
249 pid_store_cpu(i, 0, &utime, &stime); 267 pid_store_cpu(i, 0, &utime, &stime);
250 } 268 }
251 269
252 // wait 5 seconds 270 // wait 1 second
253 firemon_sleep(itv); 271 firemon_sleep(itv);
254 272
255 // grab screen size 273 // grab screen size