diff options
author | netblue30 <netblue30@yahoo.com> | 2016-11-21 08:47:33 -0500 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2016-11-21 08:47:33 -0500 |
commit | 10990a9da34bd360e48818608f46d9e9f544d0d9 (patch) | |
tree | afa139ff05a260669b0787c607250e10f4a14e25 /src/lib/pid.c | |
parent | testing (diff) | |
download | firejail-10990a9da34bd360e48818608f46d9e9f544d0d9.tar.gz firejail-10990a9da34bd360e48818608f46d9e9f544d0d9.tar.zst firejail-10990a9da34bd360e48818608f46d9e9f544d0d9.zip |
testing
Diffstat (limited to 'src/lib/pid.c')
-rw-r--r-- | src/lib/pid.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/lib/pid.c b/src/lib/pid.c index ed583c51d..42687274e 100644 --- a/src/lib/pid.c +++ b/src/lib/pid.c | |||
@@ -34,10 +34,9 @@ int max_pids=32769; | |||
34 | void pid_getmem(unsigned pid, unsigned *rss, unsigned *shared) { | 34 | void pid_getmem(unsigned pid, unsigned *rss, unsigned *shared) { |
35 | // open stat file | 35 | // open stat file |
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 | perror("asprintf"); | 38 | errExit("asprintf"); |
39 | exit(1); | 39 | |
40 | } | ||
41 | FILE *fp = fopen(file, "r"); | 40 | FILE *fp = fopen(file, "r"); |
42 | if (!fp) { | 41 | if (!fp) { |
43 | free(file); | 42 | free(file); |
@@ -59,10 +58,9 @@ void pid_getmem(unsigned pid, unsigned *rss, unsigned *shared) { | |||
59 | void pid_get_cpu_time(unsigned pid, unsigned *utime, unsigned *stime) { | 58 | void pid_get_cpu_time(unsigned pid, unsigned *utime, unsigned *stime) { |
60 | // open stat file | 59 | // open stat file |
61 | char *file; | 60 | char *file; |
62 | if (asprintf(&file, "/proc/%u/stat", pid) == -1) { | 61 | if (asprintf(&file, "/proc/%u/stat", pid) == -1) |
63 | perror("asprintf"); | 62 | errExit("asprintf"); |
64 | exit(1); | 63 | |
65 | } | ||
66 | FILE *fp = fopen(file, "r"); | 64 | FILE *fp = fopen(file, "r"); |
67 | if (!fp) { | 65 | if (!fp) { |
68 | free(file); | 66 | free(file); |
@@ -93,10 +91,9 @@ myexit: | |||
93 | unsigned long long pid_get_start_time(unsigned pid) { | 91 | unsigned long long pid_get_start_time(unsigned pid) { |
94 | // open stat file | 92 | // open stat file |
95 | char *file; | 93 | char *file; |
96 | if (asprintf(&file, "/proc/%u/stat", pid) == -1) { | 94 | if (asprintf(&file, "/proc/%u/stat", pid) == -1) |
97 | perror("asprintf"); | 95 | errExit("asprintf"); |
98 | exit(1); | 96 | |
99 | } | ||
100 | FILE *fp = fopen(file, "r"); | 97 | FILE *fp = fopen(file, "r"); |
101 | if (!fp) { | 98 | if (!fp) { |
102 | free(file); | 99 | free(file); |
@@ -138,10 +135,8 @@ uid_t pid_get_uid(pid_t pid) { | |||
138 | 135 | ||
139 | // open status file | 136 | // open status file |
140 | char *file; | 137 | char *file; |
141 | if (asprintf(&file, "/proc/%u/status", pid) == -1) { | 138 | if (asprintf(&file, "/proc/%u/status", pid) == -1) |
142 | perror("asprintf"); | 139 | errExit("asprintf"); |
143 | exit(1); | ||
144 | } | ||
145 | 140 | ||
146 | FILE *fp = fopen(file, "r"); | 141 | FILE *fp = fopen(file, "r"); |
147 | if (!fp) { | 142 | if (!fp) { |
@@ -316,10 +311,9 @@ void pid_read(pid_t mon_pid) { | |||
316 | 311 | ||
317 | // open stat file | 312 | // open stat file |
318 | char *file; | 313 | char *file; |
319 | if (asprintf(&file, "/proc/%u/status", pid) == -1) { | 314 | if (asprintf(&file, "/proc/%u/status", pid) == -1) |
320 | perror("asprintf"); | 315 | errExit("asprintf"); |
321 | exit(1); | 316 | |
322 | } | ||
323 | FILE *fp = fopen(file, "r"); | 317 | FILE *fp = fopen(file, "r"); |
324 | if (!fp) { | 318 | if (!fp) { |
325 | free(file); | 319 | free(file); |