Improve magiskhide process/thread management

This commit is contained in:
topjohnwu 2017-04-16 02:43:19 +08:00
parent dfe4b33f2f
commit 8a2f0063d4
2 changed files with 10 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);