Commit 8a2f0063 authored by topjohnwu's avatar topjohnwu

Improve magiskhide process/thread management

parent dfe4b33f
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "magiskhide.h" #include "magiskhide.h"
#include "daemon.h" #include "daemon.h"
int sv[2], hide_pid; int sv[2], hide_pid = -1;
struct vector *hide_list, *new_list; struct vector *hide_list, *new_list;
int isEnabled = 0; int isEnabled = 0;
...@@ -88,6 +88,13 @@ void launch_magiskhide(int client) { ...@@ -88,6 +88,13 @@ void launch_magiskhide(int client) {
error: error:
write_int(client, 1); write_int(client, 1);
close(client); close(client);
if (hide_pid != -1) {
int kill = -1;
// Kill hide daemon
write(sv[0], &kill, sizeof(kill));
close(sv[0]);
waitpid(hide_pid, NULL, 0);
}
return; return;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
static int zygote_num = 0; static int zygote_num = 0;
static char init_ns[32], zygote_ns[2][32]; static char init_ns[32], zygote_ns[2][32];
static FILE *p;
static void read_namespace(const int pid, char* target, const size_t size) { static void read_namespace(const int pid, char* target, const size_t size) {
char path[32]; char path[32];
...@@ -43,6 +44,7 @@ static void quit_pthread(int sig) { ...@@ -43,6 +44,7 @@ static void quit_pthread(int sig) {
hide_list = new_list = NULL; hide_list = new_list = NULL;
isEnabled = 0; isEnabled = 0;
LOGD("proc_monitor: terminating...\n"); LOGD("proc_monitor: terminating...\n");
pclose(p);
pthread_exit(NULL); pthread_exit(NULL);
} }
...@@ -72,7 +74,6 @@ void *proc_monitor(void *args) { ...@@ -72,7 +74,6 @@ void *proc_monitor(void *args) {
int pid; int pid;
char buffer[512]; char buffer[512];
FILE *p;
// Get the mount namespace of init // Get the mount namespace of init
read_namespace(1, init_ns, 32); read_namespace(1, init_ns, 32);
......
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