diff options
author | Fred Barclay <Fred-Barclay@users.noreply.github.com> | 2017-05-24 14:13:52 -0500 |
---|---|---|
committer | Fred Barclay <Fred-Barclay@users.noreply.github.com> | 2017-05-24 14:13:52 -0500 |
commit | 96c920e166b40bbe50f216e294f2efac154a1cb2 (patch) | |
tree | fa80a34e81863ab897f2f2b8ec4124b10d023516 /src/lib/pid.c | |
parent | remove trailing whitespace from etc/ (diff) | |
download | firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.tar.gz firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.tar.zst firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.zip |
Remove trailing whitespace from src/
Diffstat (limited to 'src/lib/pid.c')
-rw-r--r-- | src/lib/pid.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/pid.c b/src/lib/pid.c index 7ae5a8d3e..ed1e7b375 100644 --- a/src/lib/pid.c +++ b/src/lib/pid.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <pwd.h> | 24 | #include <pwd.h> |
25 | #include <sys/ioctl.h> | 25 | #include <sys/ioctl.h> |
26 | #include <dirent.h> | 26 | #include <dirent.h> |
27 | 27 | ||
28 | #define PIDS_BUFLEN 4096 | 28 | #define PIDS_BUFLEN 4096 |
29 | //Process pids[max_pids]; | 29 | //Process pids[max_pids]; |
30 | Process *pids = NULL; | 30 | Process *pids = NULL; |
@@ -36,14 +36,14 @@ void pid_getmem(unsigned pid, unsigned *rss, unsigned *shared) { | |||
36 | char *file; | 36 | char *file; |
37 | if (asprintf(&file, "/proc/%u/statm", pid) == -1) | 37 | if (asprintf(&file, "/proc/%u/statm", pid) == -1) |
38 | errExit("asprintf"); | 38 | errExit("asprintf"); |
39 | 39 | ||
40 | FILE *fp = fopen(file, "r"); | 40 | FILE *fp = fopen(file, "r"); |
41 | if (!fp) { | 41 | if (!fp) { |
42 | free(file); | 42 | free(file); |
43 | return; | 43 | return; |
44 | } | 44 | } |
45 | free(file); | 45 | free(file); |
46 | 46 | ||
47 | unsigned a, b, c; | 47 | unsigned a, b, c; |
48 | if (3 != fscanf(fp, "%u %u %u", &a, &b, &c)) { | 48 | if (3 != fscanf(fp, "%u %u %u", &a, &b, &c)) { |
49 | fclose(fp); | 49 | fclose(fp); |
@@ -67,7 +67,7 @@ void pid_get_cpu_time(unsigned pid, unsigned *utime, unsigned *stime) { | |||
67 | return; | 67 | return; |
68 | } | 68 | } |
69 | free(file); | 69 | free(file); |
70 | 70 | ||
71 | char line[PIDS_BUFLEN]; | 71 | char line[PIDS_BUFLEN]; |
72 | if (fgets(line, PIDS_BUFLEN - 1, fp)) { | 72 | if (fgets(line, PIDS_BUFLEN - 1, fp)) { |
73 | char *ptr = line; | 73 | char *ptr = line; |
@@ -84,7 +84,7 @@ void pid_get_cpu_time(unsigned pid, unsigned *utime, unsigned *stime) { | |||
84 | goto myexit; | 84 | goto myexit; |
85 | } | 85 | } |
86 | 86 | ||
87 | myexit: | 87 | myexit: |
88 | fclose(fp); | 88 | fclose(fp); |
89 | } | 89 | } |
90 | 90 | ||
@@ -100,7 +100,7 @@ unsigned long long pid_get_start_time(unsigned pid) { | |||
100 | return 0; | 100 | return 0; |
101 | } | 101 | } |
102 | free(file); | 102 | free(file); |
103 | 103 | ||
104 | char line[PIDS_BUFLEN]; | 104 | char line[PIDS_BUFLEN]; |
105 | unsigned long long retval = 0; | 105 | unsigned long long retval = 0; |
106 | if (fgets(line, PIDS_BUFLEN - 1, fp)) { | 106 | if (fgets(line, PIDS_BUFLEN - 1, fp)) { |
@@ -117,7 +117,7 @@ unsigned long long pid_get_start_time(unsigned pid) { | |||
117 | if (1 != sscanf(ptr, "%llu", &retval)) | 117 | if (1 != sscanf(ptr, "%llu", &retval)) |
118 | goto myexit; | 118 | goto myexit; |
119 | } | 119 | } |
120 | 120 | ||
121 | myexit: | 121 | myexit: |
122 | fclose(fp); | 122 | fclose(fp); |
123 | return retval; | 123 | return retval; |
@@ -154,12 +154,12 @@ uid_t pid_get_uid(pid_t pid) { | |||
154 | } | 154 | } |
155 | if (*ptr == '\0') | 155 | if (*ptr == '\0') |
156 | goto doexit; | 156 | goto doexit; |
157 | 157 | ||
158 | rv = atoi(ptr); | 158 | rv = atoi(ptr); |
159 | break; // break regardless! | 159 | break; // break regardless! |
160 | } | 160 | } |
161 | } | 161 | } |
162 | doexit: | 162 | doexit: |
163 | fclose(fp); | 163 | fclose(fp); |
164 | free(file); | 164 | free(file); |
165 | return rv; | 165 | return rv; |
@@ -187,7 +187,7 @@ static void print_elem(unsigned index, int nowrap) { | |||
187 | if (user ==NULL) | 187 | if (user ==NULL) |
188 | user = ""; | 188 | user = ""; |
189 | if (cmd) { | 189 | if (cmd) { |
190 | if (col < 4 || nowrap) | 190 | if (col < 4 || nowrap) |
191 | printf("%s%u:%s:%s\n", indent, index, user, cmd); | 191 | printf("%s%u:%s:%s\n", indent, index, user, cmd); |
192 | else { | 192 | else { |
193 | char *out; | 193 | char *out; |
@@ -201,7 +201,7 @@ static void print_elem(unsigned index, int nowrap) { | |||
201 | printf("%s", out); | 201 | printf("%s", out); |
202 | free(out); | 202 | free(out); |
203 | } | 203 | } |
204 | 204 | ||
205 | free(cmd); | 205 | free(cmd); |
206 | } | 206 | } |
207 | else { | 207 | else { |
@@ -220,7 +220,7 @@ void pid_print_tree(unsigned index, unsigned parent, int nowrap) { | |||
220 | 220 | ||
221 | // Remove unused parameter warning | 221 | // Remove unused parameter warning |
222 | (void)parent; | 222 | (void)parent; |
223 | 223 | ||
224 | unsigned i; | 224 | unsigned i; |
225 | for (i = index + 1; i < (unsigned)max_pids; i++) { | 225 | for (i = index + 1; i < (unsigned)max_pids; i++) { |
226 | if (pids[i].parent == (pid_t)index) | 226 | if (pids[i].parent == (pid_t)index) |
@@ -246,13 +246,13 @@ void pid_store_cpu(unsigned index, unsigned parent, unsigned *utime, unsigned *s | |||
246 | 246 | ||
247 | // Remove unused parameter warning | 247 | // Remove unused parameter warning |
248 | (void)parent; | 248 | (void)parent; |
249 | 249 | ||
250 | unsigned utmp = 0; | 250 | unsigned utmp = 0; |
251 | unsigned stmp = 0; | 251 | unsigned stmp = 0; |
252 | pid_get_cpu_time(index, &utmp, &stmp); | 252 | pid_get_cpu_time(index, &utmp, &stmp); |
253 | *utime += utmp; | 253 | *utime += utmp; |
254 | *stime += stmp; | 254 | *stime += stmp; |
255 | 255 | ||
256 | unsigned i; | 256 | unsigned i; |
257 | for (i = index + 1; i < (unsigned)max_pids; i++) { | 257 | for (i = index + 1; i < (unsigned)max_pids; i++) { |
258 | if (pids[i].parent == (pid_t)index) | 258 | if (pids[i].parent == (pid_t)index) |
@@ -293,7 +293,7 @@ void pid_read(pid_t mon_pid) { | |||
293 | exit(1); | 293 | exit(1); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | pid_t child = -1; | 297 | pid_t child = -1; |
298 | struct dirent *entry; | 298 | struct dirent *entry; |
299 | char *end; | 299 | char *end; |
@@ -308,7 +308,7 @@ void pid_read(pid_t mon_pid) { | |||
308 | // skip PID 1 just in case we run a sandbox-in-sandbox | 308 | // skip PID 1 just in case we run a sandbox-in-sandbox |
309 | if (pid == 1) | 309 | if (pid == 1) |
310 | continue; | 310 | continue; |
311 | 311 | ||
312 | // open stat file | 312 | // open stat file |
313 | char *file; | 313 | char *file; |
314 | if (asprintf(&file, "/proc/%u/status", pid) == -1) | 314 | if (asprintf(&file, "/proc/%u/status", pid) == -1) |