If reading of some of the process details fails, the process is most
likely died while we were processing its details. Thus, there is no
good to add the entry to the process list either. The entry is now
freed instead of adding the half-read entry to the list.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
process->pid = pid;
process->tid = tid;
process->pid = pid;
process->tid = tid;
- list_add_tail(&process->list, &(*process_list)->list);
snprintf(path, sizeof(path), "/proc/%d/task/%d/maps", pid, tid);
file = fopen(path, "rb");
if (!file)
snprintf(path, sizeof(path), "/proc/%d/task/%d/maps", pid, tid);
file = fopen(path, "rb");
if (!file)
maps = parse_maps(file, pid, tid);
fclose(file);
maps = parse_maps(file, pid, tid);
fclose(file);
file = fopen(path, "rb");
if (!file)
file = fopen(path, "rb");
if (!file)
parse_pageframe(file, pageframe, maps, opts);
fclose(file);
if (read_cmdline(pid, tid, process->name, sizeof(process->name)))
parse_pageframe(file, pageframe, maps, opts);
fclose(file);
if (read_cmdline(pid, tid, process->name, sizeof(process->name)))
- return 1;
-
- if (maps == NULL)
- return 1;
- list_for_each_entry(maps, &process->maps->list, list) {
- process->pages_present += maps->pages_present;
- process->pages_swapped += maps->pages_swapped;
+ if (maps != NULL) {
+ list_for_each_entry(maps, &process->maps->list, list) {
+ process->pages_present += maps->pages_present;
+ process->pages_swapped += maps->pages_swapped;
+ }
+ list_add_tail(&process->list, &(*process_list)->list);
+
+free:
+ free(process);
+
+ return 0;
}
static int parse_pid(DIR **dir)
}
static int parse_pid(DIR **dir)