Sometime, there is a timing issue.
If the process is terminated before calling readdir() and
the directory of the process is removed, the file fails to open.
If the file fails to open, errno is set, and the logic is terminated
without reading other process information.
Change-Id: I332e076ce035bd6d66175d6886ce223aa964513a
Signed-off-by: Seungha Son <seungha.son@samsung.com>
snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
fp = fopen(buf, "r");
if (fp == 0) {
+ if (errno == ENOENT)
+ errno = 0;
fprintf(stderr, "cannot file open %s\n", buf);
return ret;
}