Some fixes

This commit is contained in:
topjohnwu
2017-04-21 23:57:21 +08:00
parent 2a985ce6c0
commit 38c867ea94
2 changed files with 6 additions and 3 deletions

View File

@@ -134,12 +134,15 @@ static void (*ps_filter_cb)(int);
static const char *ps_filter_pattern;
static void proc_name_filter(int pid) {
char buf[64];
int fd;
snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
int fd = xopen(buf, O_RDONLY);
if ((fd = open(buf, O_RDONLY)) == -1)
return;
if (fdgets(buf, sizeof(buf), fd) == 0) {
snprintf(buf, sizeof(buf), "/proc/%d/comm", pid);
close(fd);
fd = xopen(buf, O_RDONLY);
if ((fd = open(buf, O_RDONLY)) == -1)
return;
fdgets(buf, sizeof(buf), fd);
}
if (strstr(buf, ps_filter_pattern)) {