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

@ -22,7 +22,7 @@ __thread void (*err_handler)(void);
static void usage() {
fprintf(stderr,
"Magisk v" xstr(VERSION) " multi-call binary\n"
"Magisk v" xstr(MAGISK_VERSION) " multi-call binary\n"
"\n"
"Usage: %s [applet [arguments]...]\n"
" or: %s --install [SOURCE] <DIR> \n"

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)) {