Commit 38c867ea authored by topjohnwu's avatar topjohnwu

Some fixes

parent 2a985ce6
...@@ -22,7 +22,7 @@ __thread void (*err_handler)(void); ...@@ -22,7 +22,7 @@ __thread void (*err_handler)(void);
static void usage() { static void usage() {
fprintf(stderr, fprintf(stderr,
"Magisk v" xstr(VERSION) " multi-call binary\n" "Magisk v" xstr(MAGISK_VERSION) " multi-call binary\n"
"\n" "\n"
"Usage: %s [applet [arguments]...]\n" "Usage: %s [applet [arguments]...]\n"
" or: %s --install [SOURCE] <DIR> \n" " or: %s --install [SOURCE] <DIR> \n"
......
...@@ -134,12 +134,15 @@ static void (*ps_filter_cb)(int); ...@@ -134,12 +134,15 @@ static void (*ps_filter_cb)(int);
static const char *ps_filter_pattern; static const char *ps_filter_pattern;
static void proc_name_filter(int pid) { static void proc_name_filter(int pid) {
char buf[64]; char buf[64];
int fd;
snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid); 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) { if (fdgets(buf, sizeof(buf), fd) == 0) {
snprintf(buf, sizeof(buf), "/proc/%d/comm", pid); snprintf(buf, sizeof(buf), "/proc/%d/comm", pid);
close(fd); close(fd);
fd = xopen(buf, O_RDONLY); if ((fd = open(buf, O_RDONLY)) == -1)
return;
fdgets(buf, sizeof(buf), fd); fdgets(buf, sizeof(buf), fd);
} }
if (strstr(buf, ps_filter_pattern)) { if (strstr(buf, ps_filter_pattern)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment