diff --git a/native/jni/magiskhide/hide_utils.cpp b/native/jni/magiskhide/hide_utils.cpp index 8f82c7604..6bed7f6a8 100644 --- a/native/jni/magiskhide/hide_utils.cpp +++ b/native/jni/magiskhide/hide_utils.cpp @@ -20,10 +20,6 @@ map> uid_proc_map; /* uid -> list of process */ // Locks the variables above pthread_mutex_t hide_state_lock = PTHREAD_MUTEX_INITIALIZER; -#if !ENABLE_INJECT -static pthread_t monitor_thread; -#endif - void update_uid_map() { mutex_guard lock(hide_state_lock); uid_proc_map.clear(); diff --git a/native/jni/magiskhide/magiskhide.hpp b/native/jni/magiskhide/magiskhide.hpp index fbe34b3f8..fa2bb64cb 100644 --- a/native/jni/magiskhide/magiskhide.hpp +++ b/native/jni/magiskhide/magiskhide.hpp @@ -23,6 +23,7 @@ void ls_list(int client); #if !ENABLE_INJECT // Process monitoring +extern pthread_t monitor_thread; [[noreturn]] void proc_monitor(); [[noreturn]] void test_proc_monitor(); #else diff --git a/native/jni/magiskhide/proc_monitor.cpp b/native/jni/magiskhide/proc_monitor.cpp index c4a8108bd..2e311003c 100644 --- a/native/jni/magiskhide/proc_monitor.cpp +++ b/native/jni/magiskhide/proc_monitor.cpp @@ -20,6 +20,8 @@ static int inotify_fd = -1; static void new_zygote(int pid); +pthread_t monitor_thread; + /****************** * Data structures ******************/ @@ -281,6 +283,7 @@ void proc_monitor() { sigaddset(&block_set, SIGIO); sigaddset(&block_set, SIGALRM); pthread_sigmask(SIG_UNBLOCK, &block_set, nullptr); + monitor_thread = pthread_self(); struct sigaction act{}; act.sa_handler = term_thread;