line |
true |
false |
branch |
79
|
0 |
3 |
if((file_text = read_file("stat", NULL, &file_len, &mem_pool)) == NULL) { |
88
|
60 |
0 |
for(file_off = file_text; file_off; file_off = strchr(file_off, '\n')) { |
89
|
57 |
3 |
if(file_off != file_text) { |
93
|
3 |
57 |
if(strncmp(file_off, "btime", 5) == 0) { |
94
|
3 |
0 |
if(sscanf(file_off, "btime %lld", &boot_time) == 1) { |
100
|
3 |
0 |
obstack_free(&mem_pool, file_text); |
|
3 |
0 |
obstack_free(&mem_pool, file_text); |
103
|
0 |
3 |
if(boot_time == -1) { |
109
|
0 |
3 |
if((file_text = read_file("meminfo", NULL, &file_len, &mem_pool)) == NULL) { |
114
|
3 |
0 |
for(file_off = file_text; file_off; file_off = strchr(file_off, '\n')) { |
115
|
0 |
3 |
if(file_off != file_text) { |
119
|
3 |
0 |
if(strncmp(file_off, "MemTotal:", 9) == 0) { |
120
|
3 |
0 |
if(sscanf(file_off, "MemTotal: %llu", &system_memory) == 1) { |
127
|
3 |
0 |
obstack_free(&mem_pool, file_text); |
|
3 |
0 |
obstack_free(&mem_pool, file_text); |
130
|
0 |
3 |
if(total_memory == -1) { |
137
|
0 |
3 |
obstack_free(&mem_pool, NULL); |
|
0 |
0 |
obstack_free(&mem_pool, NULL); |
142
|
0 |
0 |
obstack_free(&mem_pool, NULL); |
|
0 |
0 |
obstack_free(&mem_pool, NULL); |
160
|
0 |
3 |
if(init_failed) { |
166
|
0 |
3 |
if(statfs("/proc", &sfs) == -1) { |
186
|
1484 |
212 |
for(i = field1; i <= field2; i++) { |
205
|
371 |
59 |
if(file) { |
209
|
0 |
430 |
obstack_1grow(mem_pool, '\0'); |
211
|
0 |
430 |
return (char *)obstack_finish(mem_pool); |
|
0 |
430 |
return (char *)obstack_finish(mem_pool); |
240
|
271 |
0 |
obstack_free(mem_pool, file); |
|
271 |
0 |
obstack_free(mem_pool, file); |
242
|
0 |
271 |
if(fd == -1) { |
247
|
612 |
271 |
for(*len = 0; result; *len += result) { |
248
|
162 |
450 |
obstack_blank(mem_pool, 1024); |
251
|
0 |
612 |
if((result = read(fd, start, 1024)) == -1) { |
252
|
0 |
0 |
obstack_free(mem_pool, obstack_finish(mem_pool)); |
|
0 |
0 |
obstack_free(mem_pool, obstack_finish(mem_pool)); |
|
0 |
0 |
obstack_free(mem_pool, obstack_finish(mem_pool)); |
|
0 |
0 |
obstack_free(mem_pool, obstack_finish(mem_pool)); |
262
|
0 |
271 |
text = obstack_finish(mem_pool); |
|
0 |
271 |
text = obstack_finish(mem_pool); |
291
|
53 |
0 |
obstack_free(mem_pool, path_pid); |
|
53 |
0 |
obstack_free(mem_pool, path_pid); |
293
|
0 |
53 |
if(result == -1) { |
324
|
0 |
53 |
if((stat_text = read_file(pid, "stat", &stat_len, mem_pool)) == NULL) { |
328
|
0 |
53 |
if(sscanf(stat_text, "%d (", &prs->pid) != 1) { |
335
|
0 |
53 |
if((close_paren = strrchr(stat_text, ')')) == NULL) { |
341
|
0 |
53 |
if((open_paren = strchr(stat_text, '(')) == NULL) { |
350
|
0 |
53 |
if(comm_len > comm_esize) { |
353
|
53 |
0 |
if(comm_len > 0) { |
423
|
0 |
53 |
if(result != 33) { |
432
|
53 |
0 |
obstack_free(mem_pool, stat_text); |
|
53 |
0 |
obstack_free(mem_pool, stat_text); |
452
|
106 |
0 |
obstack_free(mem_pool, link_file); |
|
106 |
0 |
obstack_free(mem_pool, link_file); |
454
|
0 |
106 |
if(link == NULL) { |
461
|
0 |
106 |
obstack_1grow(mem_pool, '\0'); |
463
|
0 |
106 |
*ptr = (char *)obstack_finish(mem_pool); |
|
0 |
106 |
*ptr = (char *)obstack_finish(mem_pool); |
476
|
0 |
53 |
if((cmndline_text = read_file(pid, "cmdline", &cmndline_off, mem_pool)) == NULL) { |
481
|
7430 |
53 |
for(cur = cmndline_text; cur < cmndline_text + cmndline_off - 1; cur++) { |
482
|
342 |
7088 |
if(*cur == '\0') { |
497
|
0 |
53 |
if((cmdline_text = read_file(pid, "cmdline", &cmdline_off, mem_pool)) == NULL) { |
512
|
0 |
53 |
if((environ_text = read_file(pid, "environ", &environ_off, mem_pool)) == NULL) { |
528
|
0 |
53 |
if((status_text = read_file(pid, "status", &status_len, mem_pool)) == NULL) { |
542
|
530 |
0 |
for(loc = status_text; loc; loc = strchr(loc, '\n')) { |
544
|
477 |
53 |
if(loc != status_text) { |
548
|
53 |
477 |
if(strncmp(loc, "Uid:", 4) == 0) { |
551
|
53 |
424 |
} else if(strncmp(loc, "Gid:", 4) == 0) { |
554
|
53 |
371 |
} else if(strncmp(loc, "TracerPid:", 10) == 0) { |
560
|
106 |
424 |
if(islower(format_str[F_EUID]) && islower(format_str[F_EGID]) && islower(format_str[F_TRACER])) { |
|
53 |
53 |
if(islower(format_str[F_EUID]) && islower(format_str[F_EGID]) && islower(format_str[F_TRACER])) { |
|
53 |
0 |
if(islower(format_str[F_EUID]) && islower(format_str[F_EGID]) && islower(format_str[F_TRACER])) { |
566
|
53 |
0 |
obstack_free(mem_pool, status_text); |
|
53 |
0 |
obstack_free(mem_pool, status_text); |
673
|
0 |
53 |
if(len >= LENGTH_PCTCPU) { |
681
|
53 |
0 |
if(system_memory > 0) { |
694
|
449 |
53 |
for(; *str; str++) { |
695
|
310 |
139 |
if(!isdigit(*str)) { |
709
|
0 |
0 |
obstack_1grow(mem_pool, '\0'); |
710
|
0 |
0 |
pid_dir_path = obstack_finish(mem_pool); |
|
0 |
0 |
pid_dir_path = obstack_finish(mem_pool); |
715
|
0 |
0 |
obstack_free(mem_pool, pid_dir_path); |
|
0 |
0 |
obstack_free(mem_pool, pid_dir_path); |
740
|
0 |
5 |
dir_ent = obstack_alloc(&mem_pool, sizeof(struct dirent)); |
|
0 |
5 |
dir_ent = obstack_alloc(&mem_pool, sizeof(struct dirent)); |
|
0 |
5 |
dir_ent = obstack_alloc(&mem_pool, sizeof(struct dirent)); |
742
|
0 |
5 |
if((dir = opendir("/proc")) == NULL) { |
747
|
368 |
0 |
while(readdir_r(dir, dir_ent, &dir_result) == 0 && dir_result) { |
|
363 |
5 |
while(readdir_r(dir, dir_ent, &dir_result) == 0 && dir_result) { |
749
|
310 |
53 |
if(!is_pid(dir_result->d_name)) { |
754
|
0 |
53 |
prs = obstack_alloc(&mem_pool, sizeof(struct procstat)); |
|
0 |
53 |
prs = obstack_alloc(&mem_pool, sizeof(struct procstat)); |
|
0 |
53 |
prs = obstack_alloc(&mem_pool, sizeof(struct procstat)); |
759
|
0 |
53 |
obstack_1grow(&mem_pool, '\0'); |
760
|
0 |
53 |
format_str = (char *)obstack_finish(&mem_pool); |
|
0 |
53 |
format_str = (char *)obstack_finish(&mem_pool); |
766
|
0 |
53 |
if(get_proc_stat(dir_result->d_name, format_str, prs, &mem_pool) == false) { |
768
|
0 |
0 |
if(pid_exists(dir_result->d_name, &mem_pool) == false) { |
844
|
13 |
40 |
obstack_free(&mem_pool, prs); |
|
0 |
13 |
obstack_free(&mem_pool, prs); |
850
|
0 |
5 |
obstack_free(&mem_pool, NULL); |
|
0 |
0 |
obstack_free(&mem_pool, NULL); |