Commit 8a2f0063 authored by topjohnwu's avatar topjohnwu

Improve magiskhide process/thread management

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